Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 cooling their heels in the Monastery: (5)
As of 2015-07-03 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls