in reply to Re: More DBI Problems!!!
in thread More DBI Problems!!!

I think repson must be right that you meant to use $query->fetchrow_array instead of $dbh->selectrow_array($query).

However, the $dbh->select... methods can take an already prepared statement handle as the first argument. This allows you to prepare the statement once ahead of time, and then execute it with select... many times. For example:

my $sth = $dbh->prepare(<<EndOfSQL); SELECT name FROM item WHERE id = ? EndOfSQL while (<>) { chomp; if (($name) = $dbh->selectrow_array($sth, {}, $_)) { print "$_ => $name\n"; } else { print "$_ not found\n"; } }