Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2016-10-23 17:12 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (301 votes). Check out past polls.