by Michael Neumann (mneumann@fantasy-coders.de)
$Id: DBI_SPEC,v 1.3 2003/01/22 10:52:03 mneumann Exp $
API_VERSIONVERSIONSQL_FETCH_NEXTSQL_FETCH_PRIORSQL_FETCH_FIRSTSQL_FETCH_LASTSQL_FETCH_ABSOLUTEStatementHandle#fetch_scroll.SQL_BITSQL_TINYINTSQL_SMALLINTSQL_INTEGERSQL_BIGINTSQL_FLOATSQL_REALSQL_DOUBLESQL_NUMERICSQL_DECIMALSQL_CHARSQL_VARCHARSQL_LONGVARCHARSQL_DATESQL_TIMESQL_TIMESTAMPSQL_BINARYSQL_VARBINARYSQL_LONGVARBINARYSQL_OTHERException classes were "borrowed" from Python API 2.0.
Warning < RuntimeErrorError < RuntimeErrorInterfaceError < ErrorNotImplementedError < InterfaceErrorDatabaseError < ErrorException for errors related to the database.
Has three attributes: err, errstr and state.
DataError < DatabaseErrorOperationalError < DatabaseErrorIntegrityError < DatabaseErrorInternalError < DatabaseErrorProgrammingError < DatabaseErrorNotSupportedError < DatabaseErrorDBI.connect( driver_url, user=nil, auth=nil, params=nil )Connect to the database specified by driver_url, which may look like "dbi:Oracle:oracle.neumann".
Returns a DBI::DatabaseHandle object, or if called with a code-block,
calls this block with the new DBI::DatabaseHandle as parameter and
calls disconnect after calling the block if it was not yet disconnected by
the user.
DBI.available_driversArray of all available DBD drivers.
The strings which represent the DBD drivers are partial DSNs
(e.g., "dbi:Oracle:").DBI.data_sources( driver )DBI.disconnect_all( driver=nil )nil.DBI.trace(mode=nil, output=nil)Sets the trace mode for all subsequently created Handles to these values.
If a parameter is nil, the value is not changed.
mode defaults to 2 if it is nil, and output to STDERR if a value was not
previously set.
For mode, the values 0, 1, 2 or 3 are allowed.
Note: Tracing is only activated if you load the module "dbi/trace", because tracing currently depends on AspectR > 0.3.3.
Abstract base class for all "Handles" (DriverHandle, DatabaseHandle, StatementHandle).
func( function, *values )trace(mode=nil, output=nil)Sets the trace mode for this handle as well as for all sub-handles (in the case of DriverHandle and DatabaseHandle).
If a parameter is nil, the value is not changed.
mode defaults to 2 if it is nil, and output to STDERR if a value was not
previously set.
For mode, the values 0, 1, 2 or 3 are allowed.
Note: Tracing is only activated if you load the module "dbi/trace", because tracing currently depends on AspectR > 0.3.3.
DBI::Handleconnected?true if the connection was not yet disconnected
by calling disconnect, otherwise false.disconnectprepare( stmt )prepare( stmt ) {|statement_handle| aBlock}DBI::StatementHandle, or if called with a code-block,
calls the block with the handle as its parameter and after that
calls #finish onto the handle to free all resourcesexecute( stmt, *bindvars )execute( stmt, *bindvars ) {|statement_handle| aBlock}Immediately executes the SQL statement stmt after binding the values in bindvars to the placeholders in the statement.
Returns a DBI::StatementHandle, or if called with a code-block,
calls the block with the handle as its parameter and after that
calls #finish onto the handle to free all resources.
do( stmt, *bindvars )DBI::StatementHandle.select_one( stmt, *bindvars)DBI::Row object. select_all( stmt, *bindvars)Executes the statement after binding the values to the parameters, then returns all
resulting rows as an array of DBI::Row objects.
If called as an iterator, the passed DBI::Row objects are only references.
tablescolumns( table )DBI::ColumnInfo object for each column
in the table.pingReturns true if the connection is active, otherwise false.
In contrast to connected?, ping tests if the connection is still active by executing some SQL or doing something else.
quote( value )commitrollbacktransaction {|database_handle| aBlock}[attr][attr] = valtrue or false. Attributes are database dependent.DBI::HandleEnumerablebind_param( param, value, attribs=nil )Binds the value value to a placeholder.
The placeholder is represented by param, which is either a
String representing the name of the
placeholder used in the SQL statement (e.g., Oracle: "SELECT * FROM EMP WHERE ENAME = :ename"),
or an integer that indicates the number of the placeholder.
Placeholder numbers begin at 1.
attribs is not yet used in this version, but could later be a hash containing more information like parameter type, etc.
execute( *bindvars )finishcancelcolumn_namesArray of all column names.column_infoArray containing a DBI::ColumnInfo object for each column
in the result set.rowsnil if no such exists.fetchable?true if you can fetch rows using fetch, etc.fetchReturns a DBI::Row object, or nil if there are
no more rows to fetch.
When called as an iterator, the block is called for each row
until no more rows are available. Each row is passed to the
block as a DBI::Row object.
Note that the returned or passed DBI::Row object is only a reference and
should be copied (dup) if it is stored elsewhere.
each {|row| aBlock }fetch_arrayReturns the current row as an Array or nil if no more
rows are available.
Can also be called as an iterator.
fetch_hashReturns the current row as a Hash or nil if no more
rows are available.
Can also be called as an iterator.
fetch_many( cnt )Returns an Array of the next cnt rows, which are
stored as DBI::Row objects.
Returns the empty array [] if there are no more rows.
fetch_allfetch_scroll( direction, offset=1 )direction is one of the following constants:
offset is a positive or negative number (only when SQL_FETCH_RELATIVE is used).
fetch_scroll does not automatically free the result set if no more rows are available, e.g., if you get the last row.
Returns a DBI::Row object, or nil if no row is available.
Note that the returned DBI::Row object is only a reference and
should be copied (dup) if it is stored elsewhere.
[attr][attr] = val