in reply to Explanation of Code Problem

I think you're the OP is misunderstanding the use of placeholders here. Typically you would use placeholders like so

my $sql = q{SELECT * FROM tblX WHERE condition = ?}; $sth = $dbh->prepare($sql); $sth->execute($value_to_sub_for_question_mark);
So it seems what you are trying to do is have a long list of placeholders and then specify the values to use for the placeholders sometime before the execute is called. You want the statement to have all the ? marks in it. It doesn't need to be re-prepped that way. (Part of the beauty of placeholders)

However to do what you are wanting i think you would do this

my $sql = q{SELECT * FROM tblX WHERE condition1 = ? and condition2 = ? +}; my $sth = $dbh->prepare($sql); $sth->execute(@array);
That is untested and you may need to put the array in list context, but i think that's your intent.. just a guess


Grygonos

Replies are listed 'Best First'.
Re^2: Explanation of Code Problem
by Anonymous Monk on Jan 04, 2005 at 16:30 UTC
    What I am trying to do is to submit a bunch of, let's say account numbers per example; I am getting values previously from another DB query and the results from this query I am doing a
    push @claim,$accounts;

    and trying to run my sql query on each account number found, and I am just trying to get the better and fastest way to do it.

      ITSOTIMTOWDI

      my $sql = "QUERY WHERE ?"; my $sth = $dbh->prepare($sql); foreach(@acct) { $sth->execute($_); #do some other processing }
      That would be one way to query them all individually

        I treid something like that;
        while (@array) { $element = shift @array #other processing }


        But, are you using the "?" as a place holder? How would I use the values of the @array in my $sql?