Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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]
[LanX]: inspect %INC ?
[Lady_Aleena]: LanX, for every module I've written?
[huck]: Lady_Aleena see Re: pl script in webserver and/or Re: pl script in webserver for what they use
[Lady_Aleena]: Wouldn't I have to run the modules somehow to get their %INC?
[huck]: the first one works just fine from the command line but requires editing
[huck]: but neither will handle autoloads

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-05-27 00:07 GMT
Find Nodes?
    Voting Booth?