Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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:

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


Comment on Re: DBI fails to return an error code
Download Code
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
Node Status?
node history
Node Type: note [id://1032917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-10-21 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (98 votes), past polls