The documentation for selecrow_array in DBI 1.49 says:

"If any method fails, and "RaiseError" is not set, selectrow_array will return
an empty list."

use DBI;
use strict;
use Data::Dumper;
my $dbh = DBI->connect('dbi:mysql:xxx','yyy','zzz');
$dbh->{RaiseError} = 0;
$dbh->{PrintError} = 0;
my @r = $dbh->selectrow_array('select xxx from yyy');
print "rows = ", $#r, "\n";
print "err = ", $dbh->err, "\n";
print "errstr = ", $dbh->errstr, "\n";
print Dumper(@r);

and column xxx and table yyy does not exist I get:

rows = 0
err = 1146
errstr = Table 'yyy' doesn't exist
$VAR1 = undef;

when I expected -1 for rows - as in:

perl -e 'my @a=(); print $#a;' outputs -1 for an empty list, not 0 for a list
containing an undef.

It does not seem to matter what the driver is - I tried dbi::ODBC too.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development

Reply via email to