Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: DBI fails to return an error code

by rtillian (Initiate)
on May 10, 2013 at 09:12 UTC ( [id://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:

http://search.cpan.org/~capttofu/DBD-mysql-4.023/lib/DBD/mysql.pm

There you find:

DATABASE HANDLES

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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1032917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-16 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found