KEVIN ZEMBOWER wrote:

I'm using a function from DBI that needs a hash reference according to the 
documentation, and I don't know how to turn $_ into one. The section of code I 
have is:
  if ($record{"Author"}) {
     my @indfields = split(/\|/, $record{"Author"});
     foreach (@indfields) {
        my $authorid = $dbh->selectrow_array("SELECT authorid FROM author WHERE name 
= ?", $_)
           or die "Can't execute statement: $DBI::errstr";




perldoc DBI

The second argument to this is a hashref of DBI handle attributes not the bind values

you want:

$dbh->selectrow_array($sql, \%db_attrs, ($_));

somewhere above:
our %db_attrs = (
   RaiseError => 1,
   PrintError => 0,
   AutoCommit => 1,
   Taint      => 1
   ......
);

Also, the how point of using bind values is you should $dbh->prepare() your query outside of the loop.

then $sth->execute($_) in the loop.

and $sth->finish() after the loop.

Check out $sth->fetchrow_arrary() instead.

HTH

--
END
-----------------------------------------------------------------------------
Philip M. Gollucci
Senior Developer - Liquidity Services Inc.
Phone:  202.558.6268 (Direct)
E-Mail: [EMAIL PROTECTED]
Web:    http://www.liquidation.com


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to