These attributes are common to all types of DBI handles.
Some attributes are inherited by child handles. That is, the value of an inherited attribute in a newly created statement handle is the same as the value in the parent database handle. Changes to attributes in the new statement handle do not affect the parent database handle and changes to the database handle do not affect existing statement handles, only future ones.
Attempting to set or get the value of an unknown attribute is fatal, except for private driver-specific attributes (which all have names starting with a lowercase letter).
For example:
$h->{AttributeName} = ...; # set/write ... = $h->{AttributeName}; # get/read
Warn ( boolean, inherited) |
Enables useful warnings for certain bad practices. Enabled by default. Some emulation layers, especially those for Perl 4 interfaces, disable warnings. Since warnings are generated using the Perl warn function, they can be intercepted using the Perl $SIG{_ _WARN_ _} hook.
Active ( boolean, read-only) |
True if the handle object is "active." This is rarely used in applications. The exact meaning of active is somewhat vague at the moment. For a database handle, it typically means that the handle is connected to a database ($dbh->disconnect sets Active off ). For a statement handle, it typically means that the handle is a SELECT that may have more data to fetch. (Fetching all the data or calling $sth->finish sets Active off.)
Kids (integer, read-only) |
For a driver handle, Kids is the number of currently existing database handles that were created from that driver handle. For a database handle, Kids is the number of currently existing statement handles that were created from that database handle.
CachedKids (hash ref) |
For a database handle, returns a reference to the cache (hash) of statement handles created by the prepare_cached method. For a driver handle, returns a reference to the cache (hash) of database handles created by the connect_cached method.
CompatMode ( boolean, inherited) |
Used by emulation layers (such as Oraperl) to enable compatible behavior in the underlying driver (e.g., DBD::Oracle) for this handle. Not normally set by application code.
InactiveDestroy ( boolean) |
This attribute can be used to disable the database engine related effect of destroying a handle (which would normally close a prepared statement or disconnect from the database, etc.).
PrintError ( boolean, inherited) |
This attribute can be used to force errors to generate warnings (using warn) in addition to returning error codes in the normal way. When set "on," any method that results in an error occurring will cause the DBI to effectively do a warn("$class $method failed: $DBI::errstr") where $class is the driver class, and $method is the name of the method which failed.
DBD::Oracle::db prepare failed: ... error text here ...
RaiseError ( boolean, inherited) |
This attribute can be used to force errors to raise exceptions rather than simply return error codes in the normal way. It is "off " by default. When set to "on", any method that results in an error will cause the DBI to effectively do a die("$class $method failed: $DBI::errstr"), where $class is the driver class, and $method is the name of the method that failed. For example:
DBD::Oracle::db prepare failed: ... error text here ...
{ local $h->{RaiseError}; # localize and turn off for this block ... }
ChopBlanks ( boolean, inherited) |
This attribute can be used to control the trimming of trailing space characters from fixed-width character (CHAR) fields. No other field types are affected, even where field values have trailing spaces.
LongReadLen (unsigned integer, inherited) |
This attribute may be used to control the maximum length of long fields ("blob," "memo," etc.), which the driver will read from the database automatically when it fetches each row of data. The LongReadLen attribute relates only to fetching and reading long values; it is not involved in inserting or updating them.
See LongTruncOk for more information on truncation behavior.
LongTruncOk ( boolean, inherited) |
This attribute may be used to control the effect of fetching a long field value that has been truncated (typically because it's longer than the value of the LongReadLen attribute).
Taint ( boolean, inherited) |
If this attribute is set to a true value and Perl is running in taint mode (e.g., started with the -T option), then all data fetched from the database is tainted, and the arguments to most DBI method calls are checked for being tainted. This may change.
private_* |
The DBI provides a way to store extra information in a DBI handle as "private" attributes. The DBI will allow you to store and retrieve any attribute that has a name starting with private_. It is strongly recommended that you use just one private attribute (e.g., use a hash ref) and give it a long and unambiguous name that includes the module or application name that the attribute relates to (e.g., private_YourFullModuleName_thingy).
Copyright © 2001 O'Reilly & Associates. All rights reserved.