This section lists the values that can be
added to the optional %attributes
hash that
appears in many Perl DBI methods. The basic syntax to set an
attribute is $handle->{attribute} =
'setting';
to retrieve a setting use
$handle->{attribute}
.
You can use the following attributes with both database handles and statement handles.
Active
Instructs the server that the handle
should remain open until terminated explicitly by finish()
or disconnect( )
depending on the
handle type.
ActiveKids
Provides the number of active handles under the handle that employed the attribute. If it’s set by a database handle, then the number of active statement handles will be returned. If it’s called by a database handle, the number of active statement handles will be returned. If set by a driver handle, the number of database handles will be returned.
CacheKids
Returns a reference to a
hash containing child handles for a driver or a database handle that
was created by the connect_cached( )
or
prepare_cached( )
methods, respectively.
ChopBlanks
Trims trailing spaces from fixed-width character columns.
CompatMode
Makes emulation layers compatible with a driver handle.
ErrCount
Executed
Determines whether a handle or one of its children has been executed.
FetchHashKeyName
Instructs fetchrow_hashref()
calls to convert column names to either all lowercase
(NAME_lc
) or all uppercase
(NAME_uc
) letters.
HandleError
Customizes the response to an error caused by the handle. You could use this attribute to run a subroutine in the event of an error.
HandleSetErr
Customizes the settings of an error caused
by the handle. It’s similar to the
HandleError
attribute, but it relates to
set_err( )
.
InactiveDestroy
Prevents the server from destroying a
handle that is out of scope, unless it is closed intentionally with a
function like finish( )
or disconnect( )
.
Kids
Provides the number of all handles (active and inactive) under the handle that employed the attribute. If it’s called by a database handle, the number of statement handles will be returned. If it’s called by a driver handle, the number of database handles will be returned.
LongReadLen
Sets the maximum length of data retrieved from long datatype columns
(i.e., BLOB
and TEXT
).
LongTruncOK
Prevents a fetch method from failing if a column’s
data exceeds the maximum length by the LongReadLen
attribute.
PrintError
Obtains error codes and error messages associated with the handle.
PrintWarn
Controls the warning messages that are logged.
private_*
Stores information on the handle as a private attribute with a
customized name starting with private_
.
Profile
Enables logging of method call timing statistics.
RaiseError
Raises exceptions when errors are associated with the handle.
ShowErrorStatement
Specifies text to append to error messages caused by the
PrintError
, PrintWarn
, and
RaiseError
attributes.
Taint
Combines TaintIn
and TaintOut
attributes.
TaintIn
Instructs DBI to check if method calls are tainted, when Perl is run in taint mode.
TaintOut
Instructs DBI to assume that data fetched is tainted, when Perl is running in taint mode.
TraceLevel
Sets trace levels and flags for a handle.
It’s an alternative to the trace()
method.
Warn
Enables or disables warning messages for poor database procedures.
AutoCommit
Allows the rollback( )
function to be used if attribute is 0.
Driver
Provides the name of the parent driver.
Name
Provides the name of the database for the database handle.
RowCacheSize
Provides a suggested cache size for rows generated for
SELECT
statements. If it’s 0, DBI
automatically determines the cache size. A value of 1 disables local
row caching.
Statement
Provides the last SQL statement prepared with the database handle regardless of whether it succeeded.
Username
CursorName
Sets the name of the cursor for the statement handle.
Database
Provides the database handle of the statement handle.
Name
Contains a reference to an array containing the names of the columns of the SQL statement from the statement handle.
NULLABLE
Contains a reference to an array indicating whether each column in the SQL statement of the handle may contain a NULL value.
NUM_OF_FIELDS
Returns the number of columns in the SQL statement of the handle.
NUM_OF_PARAMS
Returns the number of placeholders in the SQL statement of the handle.
ParamValues
Returns a reference to a hash of bound parameters and their values.
Statement
TYPE
Contains a reference to an array of codes for international standard
values for data-types (e.g., 1 for SQL_CHAR
, 4 for
SQL_INTEGER
).
PRECISION
Contains a reference to an array containing the length of columns (as set in the table definition) in the SQL statement of the handle.
SCALE
Contains a reference to an array containing the number of decimal places for columns in the SQL statement of the handle.
These attributes are related to the last handle used, regardless of
the type of handle. The syntax of each of these is
$DBI:
:attribute
.
18.117.233.54