thor has asked for the wisdom of the Perl Monks concerning the following question:
What surprises me is that when I call fetch on the second query, it doesn't return undef as a result of there being no data to retrieve. Any pointers to the friendly manual for this behavior?use warnings; use strict; use DBI; my $dbh = DBI->connect( "dbi:ODBC:driver={SQL Server};server=localhost;database=master", "", "", {ChopBlanks => 1, RaiseError => 1, PrintError => 0}); { my $sth = $dbh->prepare(qq( select * from sysdatabases where 9=0 )); $sth->execute(); my $counter = 0; while( $sth->fetch()) { $counter++; } print "$counter\n"; } { my $sth = $dbh->prepare(qq( select min(dbid) from sysdatabases where 9=0 )); $sth->execute(); my $counter = 0; while( $sth->fetch()) { $counter++; } print "$counter\n"; } __END__ 0 1
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI and selecting aggregate columns with no results
by RazorbladeBidet (Friar) on Mar 09, 2005 at 17:28 UTC | |
|
[OT] Re: DBI and selecting aggregate columns with no results
by trammell (Priest) on Mar 09, 2005 at 18:07 UTC | |
|
Re: DBI and selecting aggregate columns with no results
by jZed (Prior) on Mar 09, 2005 at 20:03 UTC |