You see that I connect to the database and try to fetch all rows into a hash. It works most of the time and always from the shell (though not always when called from cron - strange!) Now my problem is that sometimes there is nothing in $sth and I get the following error: DBD::Sybase::st fetchall_hashref failed: Field 'ent_id' does not exist (not one of COL(1)) at /.../.../myscript line 75. As I do error checking, it looks like it just doesn't create an error. As is is a Select statement, I also cannot use the $sth->rows to check if there are any rows.my $dbh = DBI->connect("dbi:Sybase:server=$percdb", $user, $passwd, {'RaiseError' => 1} ); if ($DBI::errstr) { FATAL($DBI::errstr); exit 1; } else { DEBUG('Successfully connected to database!'); } my $sth = $dbh->prepare($QUERY); $sth->execute; handle_db_error(); $result_hash = $sth->fetchall_hashref('ent_id'); handle_db_error(); sub handle_db_error { if ($dbh->err) { FATAL("Error: $DBI::errstr"); exit 9; } }
In reply to DBI::Sybase sometimes returns nothing, but does not generate an error -> how can I catch this? by svenXY
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |