If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I would like to run a query multiple times in a foreach loop passing different variables from an array into each query. The query works fine on its own, but doesn't in the foreach loop.
foreach (@array) {
my $sth2 = $dbh->prepare("SELECT ACCTID FROM data.csv WHERE ACCTID= ?");
$sth2->execute($_);
while (my $row2 = $sth2->fetchrow_hashref) {
push(@array2, $row2->{'ACCTID'});
}
The finish call is redundant, but aside from that, you'll have to tell us what error messages you're getting, and show your complete connection string and indicate what OS, DBMS, version of Perl you're using.