Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Answer: What is the difference between $DBI::errstr and $dbh->errstr

( #11112=categorized answer: print w/ replies, xml ) Need Help??

Q&A > database programming > What is the difference between $DBI::errstr and $dbh->errstr? contributed by btrott

$DBI::errstr is actually a variable, not a method call. It holds the text of the last error on any of the database handles.

$dbh->errstr is a method call on a database handle. It returns the text of the last error from "the last driver function called," according to the DBI manpage.

In general, you should use $dbh->errstr, unless you don't have an available database handle. For example, if you're calling DBI->connect, you're creating a database handle, so you don't actually have one to call the errstr method on. So if you're doing error checking on the connect method, you should print out $DBI::errstr if you get undefined back from connect.

When you're doing error checking for any database handle methods (prepare, execute, etc.), you should use $dbh->errstr. (Or just set RaiseError.)

Comment on Answer: What is the difference between $DBI::errstr and $dbh->errstr
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-07-23 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (130 votes), past polls