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

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2017-09-23 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (273 votes). Check out past polls.

    Notices?