Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: DBI fails to return an error code

by rtillian (Initiate)
on May 10, 2013 at 09:12 UTC ( #1032917=note: print w/replies, xml ) Need Help??

in reply to DBI fails to return an error code

Hi, the solution can be found at:

There you find:


The DBD::mysql driver supports the following attributes of database handles (read only):
$errno = $dbh->{'mysql_errno'}; <---- SOLUTION!
$error = $dbh->{'mysql_error'};
$info = $dbh->{'mysql_hostinfo'};
$info = $dbh->{'mysql_info'};
$insertid = $dbh->{'mysql_insertid'};
$info = $dbh->{'mysql_protoinfo'};
$info = $dbh->{'mysql_serverinfo'};
$info = $dbh->{'mysql_stat'};
$threadId = $dbh->{'mysql_thread_id'};

Use $dbh->{'mysql_error'} instead of $DBI::errstr like here:

my $sql = "delete from not_existing_table where ai = 12"; $dbh->do( $sqlbef ) || die "Problem: $dbh->{'mysql_error'}\n";

you will get the answer:

Problem: Table 'not_existing_table' doesn't exist

Replies are listed 'Best First'.
Re^2: DBI fails to return an error code
by mje (Curate) on May 13, 2013 at 10:57 UTC

    Nonesense. The problem was a bug in DBD::mysql. You should be able to rely on DBIs err and errstr methods.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032917]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2016-12-10 00:22 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (159 votes). Check out past polls.