Name

DBI::state

Synopsis

$sql_error  = $handle->state;

DBI::state returns the SQLSTATE SQL error code for the last error DBI encountered. Currently both DBD::mSQL and DBD::mysql report `S1000’ for all errors. This function is available from both database and statement handles. The variable $DBI::state performs the same function.

Example

Use DBI;
my $db = DBI->connect('DBI:mysql:mydata','webuser','super_secret_squirrel');
...
my $sql_error = $db->state;
warn("This is your most recent DBI SQL error: $sql_error");

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.