If no block is specified, a connection to the given data source
is established and a ODBC::Database
object is returned, identifying that connection. Otherwise,
the block is executed with the database object. When the block
is finished, the connection is automatically released.
Options are:
First commits the current transaction, then executes the given
block where the paramater is the object itself (an environment or
a database connection). If the block raises an exception, the
transaction is rolled back, otherwise committed.
The class to represent a connection to an ODBC data source.
When underlying ODBC SQL functions report an error,
an ODBC::Error
exception with a corresponding error message from the ODBC
driver manager and/or driver is raised.
Disconnects from the data source, all active statements for the
connection are dropped except when the no_drop argument
is true. The method returns true when the connection was released,
false otherwise.
Returns an ODBC::Statement
with index information
of the given table (String). If unique
is given and true, information for unique indexes only is
returned.
Returns an ODBC::Statement
with column information
of the given table (String) indicating the
optimal unique or identifying columns.
id may
be specified as ODBC::SQL_BEST_ROWID or
ODBC::SQL_ROW_VER. scope may be
specified as ODBC::SQL_SCOPE_CURROW,
ODBC::SQL_SCOPE_TRANSACTION, or
ODBC::SQL_SCOPE_SESSION. If omitted the
defaults are ODBC::SQL_BEST_ROWID and
ODBC::SQL_SCOPE_CURROW.
Prepares and executes the query as in run,
but returns the number of result rows and automatically drops
the statement. Useful for SQL insert, delete, or update statements.
Prepares the query specified by sql within a
ODBCProc and returns that procedure.
When the procedure is called, the statement is executed with
the procedure's arguments bound to the statement's parameters
and the statement is bound as parameter in the block, eg
# add customer given name and id
# and return number of affected rows
addcust = dbc.proc("insert into customer values(?, ?)") { |stmt|
stmt.nrows
}
addcust.call("J.R. User", 9999)
# alternative to call: addcust["J.R. User", 9999]
The run, prepare,
do, and info methods (eg tables)
can be invoked with a block. In this case the block is executed with
the ODBC::Statement as parameter. The
run and do methods use the ODBC API
function SQLExecDirect() when the SQL statement has no
parameters.
The class to represent the query result. The object of this
class is created as the result of every query. You may need to invoke the
close or drop methods for the finished object for better memory performance.
When underlying ODBC SQL functions report an error,
an ODBC::Error
exception with a corresponding error message from the ODBC driver
manager and/or driver is raised.
Returns a hash of column information keyed by column names
(Strings) of the query result. If as_ary is true,
an array is returned. In both cases the elements are
ODBC::Columns. If the hash keys
happen to be not unique later columns get their column number
appended, e.g. FOOBAR, FOOBAR#1.
Returns the next row of the query result as a hash keyed by
column names. If with_table_names is true,
the keys are combined table/column names. For uniqueness of keys
the same rules as in the columns
method are applied.
Returns true and switches over to the next result set,
if the query produced more than one result set. Otherwise
returns false.
Remarks:
The fetch,
fetch_hash,
and execute
methods can be invoked with a block. In this case the block is
executed with one row of the result set (fetch and
fetch_hash) or with the
ODBC::Statement (execute)
as parameter.
If the ignorecase option
is turned on, all column names used in the column,
columns, and *_hash methods are converted to
upper case.
The class to represent information of a column of a query.
Objects of this class are created as result of the column
and columns methods of
ODBC::Statement.
The class to represent a procedure with ODBC database/statement
context.
Objects of this class are created as result of a
ODBC::Database.proc method call.
The class to represent ODBC related exceptions. The descriptive
string is made up of the first ODBC driver or driver manager
message as concatenation of SQL state, native error, driver manager
name, database name/vendor, DSN, and error text, eg