Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by btrott (Parson)
on May 11, 2000 at 08:29 UTC ( #11112=categorized answer: print w/replies, xml ) Need Help??

Q&A > database programming > What is the difference between $DBI::errstr and $dbh->errstr? - Answer 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 exploiting the Monastery: (7)
As of 2016-09-25 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (471 votes). Check out past polls.