examples/dbi/error_handling.pl
$sth = $dbh->prepare($statement)   or die $dbh->errstr;
$rv  = $sth->execute(@bind_values) or die $sth->errstr;

fetchrow_array (and others) return undef when no more row or if they encounter an error. Use RaiseError or check $sth->err