A little background: I have a perl script which is performing a number of operations inside of a loop.
Inside of the loop, I create a prepared statement like so:
// inside loop
my $statement = "select xxxx from zzzzzz where $foobar;";
my $query = $connect->prepare($statement);
$query->execute();
$foobar is updated to a new value everytime the loop completes, which is why i want to change the query every run, however I am getting an error when I try to do so.
When the script is run I get this error:
DBD::Pg::st execute failed: ERROR: prepared statement "xxxxxxxxxxxxx" already exists at
Because I am passing a variable which is updated every time the loop runs, and assuming I need to use this prepared statement, how do I get around this error?
Thank you for your time.
Edit:
For future people having this problem, check this out here :
I was trying to get
my $sth = $dbh->prepare('select interval ?');
http://gborg.postgresql.org/pipermail/dbdpg-general/2006-January/001972.html
http://gborg.postgresql.org/pipermail/dbdpg-general/2006-February/002007.html
list some workarounds: either turning off the server-side prepares through the pg_server_prepare flag or using eg. '?::interval' instead of 'interval ?'