$sth->fetchrow_array () returns what it indicates: a list not a scalar
If you use bind_columns () (A GOOD CHOICE!), the call should be fetch_arrayref (), not fetch_array ()
Use UNIQUE or DISTINCT as already suggested if you want just a single value
or, remember what you saw:
$dbh->{RaiseError} = 1; my $sth = $dbh->prepare (qq; select tax_id from gene2acc where genomic_ac_ver = '$ref'; ); # qq;; is a nice way to make cut-n-paste to sql easier $sth->execute; my $tax_id; $sth->bind_columns (\$tax_id); my %seen; while ($sth->fetch) { $seen{$tax_id}++ and next; # Only use first occurance print "Entering taxID_format with $tax_id\n"; #taxID_format ($tax_id); } keys %seen or print "No records matched for $ref\nn";
In reply to Re: dbi retieve single col value
by Tux
in thread dbi retieve single col value
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |