But, both of these do not appear to hamper your code at all - instead, i'll wager that there is only one record with the the phone number 8673509 (Jenny!).
Try this instead - take out the WHERE clause and run your code again, i'll bet you get something this time. If not then replace the fetchrow_array fetch with the fetchrow_hashref fetch.
Also, add use strict; at the top with your other use statements and add my to each new occurance of a variable. You have one for $DSN, $dbh, and $sql - add them to $sth, @row, and $hashrow - it is just good practice to do so.
<UPDATE>
usrbinperl++ and jsprat++ This is all the more reason
to always, always use strict: because the code would not
even compile due to the fact that you forgot two simple
characters: - and > (jeffa needs to quit
wagering, he keeps losing) ;)
</UPDATE>
Lastly, use Data::Dumper to inspect what fetchrow_hashref returns. Quick and easy:
use DBI; use Data::Dumper; use strict; my $dbh = DBI->connect( qw(DBI:vendor:database:host user pass), {RaiseError=>1} ); # setting RaiseError to true will cause your script to # die with an error message from all database errors my $sth = $dbh->prepare(" select * from mp3.songs limit 200 "); $sth->execute; my $hashrow = $sth->fetchrow_hashref; print Dumper $hashrow; # or just print Dumper $sth->fetchrow_hashref;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: DBI and fetchrow_hashref
by jeffa
in thread DBI and fetchrow_hashref
by jeff867
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |