Common Attributes
Common attributes are those that can be queried and set within both database and statement handles. This section discusses some of the most commonly used attributes, including:
- PrintError
The
PrintErrorattribute, when enabled, will cause the DBI to issue a warning when a DBI method returns with an error status. This functionality is extremely useful for rapid debugging of your programs, as you may not have written explicit return value checking code after every DBI statement.The printed error string lists the class of the database driver through which the DBI method was dispatched, the method that caused the error to occur, and the value of
$DBI::errstr. The following message was generated when theprepare()method did not successfully execute against an Oracle7 database using theDBD::Oracledriver:DBD::Oracle::db prepare failed: ORA-00904: invalid column name (DBD: error possibly near <*> indicator at char 8 in ' SELECT <*>nname, location, mapref FROM megaliths ') at /opt/WWW/apache/cgi-bin/megalith/megadump line 79.PrintErroruses the standard Perl function calledwarn()to render the error message. Therefore, you could use a$SIG{_ _WARN_ _}error handler or an error handling module such asCGI::ErrorWrapto re-route the error messages fromPrintError.This attribute is enabled by default.
- RaiseError
The
RaiseErrorattribute is similar in style to itsPrintErrorcousin, but differs slightly in operation. WhereasPrintErrorsimply displayed a message when ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access