in reply to $DBI::errstr is always undef
Setting RaiseError as you do will cause an exception to be thrown on all errors (except I think errors during the connect() call). That means that $dbh->prepare should either throw an exception or return a valid statement handle.
Also, testing with mysql throws an error only when you execute the query object. Oracle might behave differently ofcourse:
output:use strict; use warnings; use DBI; my $dbh = DBI->connect( "dbi:mysql:test", "root", "", {AutoCommit => 0 +, RaiseError => 1, PrintError => 0}) || die "Can't connect to databas +e: $DBI::errstr"; my $qry = $dbh->prepare(q{ select BAD__column from users where id=1254 +3256 }) or die "Prepare bad: $DBI::errstr"; $qry->execute();
DBD::mysql::st execute failed: Table 'test.users' doesn't exist at tes +t.pl line 8. Issuing rollback() for database handle being DESTROY'd without explici +t disconnect().
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $DBI::errstr is always undef
by runrig (Abbot) on Mar 02, 2007 at 22:48 UTC | |
by jettero (Monsignor) on Mar 03, 2007 at 12:12 UTC |