Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:47:47+00:00 2026-06-06T08:47:47+00:00

A little background: I have a perl script which is performing a number of

  • 0

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 ?’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:47:49+00:00Added an answer on June 6, 2026 at 8:47 am

    Move your prepared statement outside of the loop. If you have a variable that needs to be passed to the prepared statement, you’ll use the ? marker to pass in the variable to the prepared statement. Here’s an example:

    my $stmt = $dbh->prepare('SELECT * FROM table WHERE id = ?');
    foreach ... {
    
        my $var = <something>;
        $stmt->execute($var);
    }
    

    Here, the prepared statement is created once, and the ? is used to pass in variables. When you call execute, you pass in the variable as parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little Background: I have csv file which has lots of rows and each row
A little background information: I have a table called table_a , which has 12
First a little background: I have already managed to connect to a Microsoft SOAP
First, a little background. I have strings that resemble the following: ((Foo.Bar.StartsWith(A)) && (Foo.Bar.EndsWith(B)))
I have a strong database background but very little practical experience with ms sql
A little background: I am loading a WPF UI from a database which is
A little background first. I've been tasked with encrypting files with a Powershell script
A little background: I'm using Spring and Hibernate to create a really simple domain/dao/service
First, a little background : I have written a little application in python with
A little background: I'm a C# developer starting to mess with the iPhone (have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.