Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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

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
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 cooling their heels in the Monastery: (5)
As of 2016-10-01 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (579 votes). Check out past polls.