in reply to dbi retieve single col value
$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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dbi retieve single col value
by gone2015 (Deacon) on Aug 28, 2008 at 17:00 UTC | |
|
Re^2: dbi retieve single col value
by Anonymous Monk on Aug 28, 2008 at 13:24 UTC | |
by Anonymous Monk on Aug 28, 2008 at 13:26 UTC | |
by Tux (Canon) on Aug 28, 2008 at 15:00 UTC |