svenXY has asked for the wisdom of the Perl Monks concerning the following question:
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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI::Sybase sometimes returns nothing, but does not generate an error -> how can I catch this?
by runrig (Abbot) on Jan 11, 2005 at 17:24 UTC | |
by svenXY (Deacon) on Jan 12, 2005 at 07:46 UTC | |
|
Re: DBI::Sybase sometimes returns nothing, but does not generate an error -> how can I catch this?
by jfroebe (Parson) on Jan 11, 2005 at 19:05 UTC | |
by svenXY (Deacon) on Jan 12, 2005 at 08:43 UTC | |
by mpeppler (Vicar) on Jan 12, 2005 at 20:33 UTC | |
by svenXY (Deacon) on Jan 13, 2005 at 08:59 UTC |