Parameters

Return Values

IBM_DB::autocommit — Returns or sets the AUTOCOMMIT state for a
database connection

Description

mixed IBM_DB::autocommit ( resource connection [, bool value] )

Returns or sets the AUTOCOMMIT behavior of the specified connection
resource.

Parameters

connection

A valid database connection resource variable as returned from connect() or pconnect().

value

One of the following constants:
DB2_AUTOCOMMIT_OFF
Turns AUTOCOMMIT off.
DB2_AUTOCOMMIT_ON
Turns AUTOCOMMIT on.

Return Values

When IBM_DB::autocommit() receives only the connection parameter, it
returns the current state of AUTOCOMMIT for the requested connection as an
integer value. A value of 0 indicates that AUTOCOMMIT is off, while a value
of 1 indicates that AUTOCOMMIT is on.

When IBM_DB::autocommit() receives both the connection parameter and autocommit parameter, it attempts to set the
AUTOCOMMIT state of the requested connection to the corresponding state.

Description

Binds a Ruby variable to an SQL statement parameter in a statement resource
returned by IBM_DB::prepare(). This function gives you more control over
the parameter type, data type, precision, and scale for the parameter than
simply passing the variable as part of the optional input array to
IBM_DB::execute().

Parameters

stmt

A prepared statement returned from IBM_DB::prepare().

parameter-number

Specifies the 1-indexed position of the parameter in the prepared statement.

variable-name

A string specifying the name of the Ruby variable to bind to the parameter specified by parameter-number.

parameter-type

A constant specifying whether the Ruby variable should be bound to the SQL parameter as an input parameter
(SQL_PARAM_INPUT), an output parameter (SQL_PARAM_OUTPUT), or as a parameter that accepts input and returns output
(SQL_PARAM_INPUT_OUTPUT). To avoid memory overhead, you can also specify PARAM_FILE to bind the Ruby variable
to the name of a file that contains large object (BLOB, CLOB, or DBCLOB) data.

data-type

A constant specifying the SQL data type that the Ruby variable should be bound as: one of SQL_BINARY,
DB2_CHAR, DB2_DOUBLE, or DB2_LONG .

precision

Specifies the precision that the variable should be bound to the database.

scale

Specifies the scale that the variable should be bound to the database.

size

Specifies the size that should be retreived from an INOUT/OUT parameter.

Return Values

IBM_DB::client_info — Returns an object with properties that describe
the DB2 database client

Description

object IBM_DB::client_info ( resource connection )

This function returns a read-only object with information about the DB2
database client. The following table lists the DB2 client properties:

Table 1. DB2 client properties

Property name:

Description (Return type)

APPL_CODEPAGE:

The application code page. (int)

CONN_CODEPAGE:

The code page for the current connection. (int)

DATA_SOURCE_NAME:

The data source name (DSN) used to create the current connection to the
database. (string)

DRIVER_NAME:

The name of the library that implements the DB2 Call Level Interface (CLI)
specification. (string)

DRIVER_ODBC_VER:

The version of ODBC that the DB2 client supports. This returns a string
"MM.mm" where MM is the major version and mm is the minor
version. The DB2 client always returns "03.51". (string)

DRIVER_VER:

The version of the client, in the form of a string "MM.mm.uuuu"
where MM is the major version, mm is the minor version, and uuuu is the
update. For example, "08.02.0001" represents major version 8,
minor version 2, update 1. (string)

The version of ODBC that the ODBC driver manager supports. This returns a
string "MM.mm.rrrr" where MM is the major version, mm is the
minor version, and rrrr is the release. The DB2 client always returns
"03.01.0000". (string)

Parameters

Return Values

Description

bool IBM_DB::close ( resource connection )

This function closes a DB2 client connection created with IBM_DB::connect()
and returns the corresponding resources to the database server.

If you attempt to close a persistent DB2
client connection created with IBM_DB::pconnect(), the close request returns TRUE and the
persistent DB2 client connection remains available for the next caller.

Description

bool IBM_DB::commit ( resource connection )

Commits an in-progress transaction on the specified connection resource and
begins a new transaction. Ruby applications normally default to AUTOCOMMIT
mode, so IBM_DB::commit() is not necessary unless AUTOCOMMIT has been
turned off for the connection resource.

Note: If the specified connection resource is a persistent
connection, all transactions in progress for all applications using that
persistent connection will be committed. For this reason, persistent
connections are not recommended for use in applications that require
transactions.

Parameters

connection

A valid database connection resource variable as returned from IBM_DB::connect() or IBM_DB::pconnect().

Return Values

IBM_DB::conn_error — Returns a string containing the SQLSTATE
returned by the last connection attempt

Description

string IBM_DB::conn_error ( [resource connection] )

IBM_DB::conn_error() returns an SQLSTATE value representing the reason the
last attempt to connect to a database
failed. As IBM_DB::connect() returns FALSE in the event of a failed
connection attempt, you do not pass any parameters to IBM_DB::conn_error()
to retrieve the SQLSTATE value.

If, however, the connection was successful but becomes invalid over time,
you can pass the connection parameter to retrieve the SQLSTATE value for a
specific connection.

To learn what the SQLSTATE value means, you can issue the following command
at a DB2 Command Line Processor prompt: db2 ’? sqlstate-value’.
You can also call IBM_DB::conn_errormsg() to retrieve an explicit error
message and the associated SQLCODE value.

Parameters

connection

A connection resource associated with a connection that initially succeeded, but which over time

became invalid.

Return Values

Returns the SQLSTATE value resulting from a failed connection attempt.
Returns an empty string if there is no error associated with the last
connection attempt.

Description

string IBM_DB::conn_errormsg ( [resource connection] )

IBM_DB::conn_errormsg() returns an error message and SQLCODE value
representing the reason the last database connection attempt failed. As
IBM_DB::connect() returns FALSE in the event of a failed connection
attempt, do not pass any parameters to IBM_DB::conn_errormsg() to retrieve
the associated error message and SQLCODE value.

If, however, the connection was successful but becomes invalid over time,
you can pass the connection parameter to retrieve the associated error
message and SQLCODE value for a specific connection.

Parameters

connection

A connection resource associated with a connection that initially succeeded, but which over time

became invalid.

Return Values

Returns a string containing the error message and SQLCODE value resulting
from a failed connection attempt. If there is no error associated with the
last connection attempt, IBM_DB::conn_errormsg() returns an empty string.

Description

Creates a new connection to an IBM DB2 Universal Database, IBM Cloudscape,
or Apache Derby database.

Parameters

database

For a cataloged connection to a database, database represents the database alias in the DB2 client catalog.
For an uncataloged connection to a database, database represents a complete connection string in the following format:
DRIVER={IBM DB2 ODBC DRIVER};DATABASE=database;HOSTNAME=hostname;PORT=port;PROTOCOL=TCPIP;UID=username;PWD=password;
where the parameters represent the following values:
hostname
The hostname or IP address of the database server.
port
The TCP/IP port on which the database is listening for requests.
username
The username with which you are connecting to the database.
password
The password with which you are connecting to the database.

username

The username with which you are connecting to the database.
For uncataloged connections, you must pass a NULL value or empty string.

password

The password with which you are connecting to the database.
For uncataloged connections, you must pass a NULL value or empty string.

options

An associative array of connection options that affect the behavior of the connection,
where valid array keys include:
SQL_ATTR_AUTOCOMMIT
Passing the SQL_AUTOCOMMIT_ON value turns autocommit on for this connection handle.
Passing the SQL_AUTOCOMMIT_OFF value turns autocommit off for this connection handle.
ATTR_CASE
Passing the CASE_NATURAL value specifies that column names are returned in natural case.
Passing the CASE_LOWER value specifies that column names are returned in lower case.
Passing the CASE_UPPER value specifies that column names are returned in upper case.
CURSOR
Passing the SQL_SCROLL_FORWARD_ONLY value specifies a forward-only cursor for a statement resource.
This is the default cursor type and is supported on all database servers.
Passing the SQL_CURSOR_KEYSET_DRIVEN value specifies a scrollable cursor for a statement resource.
This mode enables random access to rows in a result set, but currently is supported
only by IBM DB2 Universal Database.

Return Values

Returns a connection handle resource if the connection attempt is
successful. If the connection attempt fails, IBM_DB::connect() returns
FALSE.

Description

If you plan to interpolate Ruby variables into the SQL statement,
understand that this is one of the more common security exposures. Consider
calling IBM_DB::prepare() to prepare an
SQL statement with parameter markers for input values. Then you can call
IBM_DB::execute() to pass in the input values and avoid SQL injection
attacks.

If you plan to repeatedly issue the same SQL statement with different
parameters, consider calling IBM_DB::prepare() and IBM_DB::execute() to
enable the database server to reuse its access plan and increase the
efficiency of your database access.

Parameters

connection

A valid database connection resource variable as returned from IBM_DB::connect() or IBM_DB::pconnect().

statement

An SQL statement. The statement cannot contain any parameter markers.

options

An associative array containing statement options. You can use this parameter to request
a scrollable cursor on database servers that support this functionality.
cursor
Passing the SQL_SCROLL_FORWARD_ONLY value requests a forward-only cursor for this SQL statement.
This is the default type of cursor, and it is supported by all database servers.
It is also much faster than a scrollable cursor.
Passing the SQL_CURSOR_KEYSET_DRIVEN value requests a scrollable cursor for this SQL statement.
This type of cursor enables you to fetch rows non-sequentially from the database server.
However, it is only supported by DB2 servers, and is much slower than forward-only cursors.

Return Values

Returns a statement resource if the SQL statement was issued successfully,
or FALSE if the database failed to execute the SQL statement.

Description

bool IBM_DB::execute ( resource stmt [, array parameters] )

IBM_DB::execute() executes an SQL statement that was prepared by
IBM_DB::prepare().

If the SQL statement returns a result
set, for example, a SELECT statement or a CALL to a stored procedure that
returns one or more result sets, you can
retrieve a row as an array from the stmt resource using
IBM_DB::fetch_assoc(), IBM_DB::fetch_both(), or IBM_DB::fetch_array().
Alternatively, you can use IBM_DB::fetch_row() to move the result set pointer to the next row and fetch
a column at a time from that row with IBM_DB::result().

Refer to IBM_DB::prepare() for a brief discussion of the advantages of
using IBM_DB::prepare() and IBM_DB::execute() rather than IBM_DB::exec().

Parameters

stmt

A prepared statement returned from IBM_DB::prepare().

parameters

An array of input parameters matching any parameter markers contained in the prepared statement.

Return Values

IBM_DB::fetch_array — Returns an array, indexed by column position,
representing a row in a result set

Description

array IBM_DB::fetch_array ( resource stmt [, int row_number] )

Returns an array, indexed by column position, representing a row in a result set. The columns are 0-indexed.

Parameters

stmt

A valid stmt resource containing a result set.

row_number

Requests a specific 1-indexed row from the result set. Passing this parameter results in a
Ruby warning if the result set uses a forward-only cursor.

Return Values

Returns a 0-indexed array with column values indexed by the column position
representing the next or requested row in the result set. Returns FALSE if there are no
rows left in the result set, or if the
row requested by row_number does not exist in the result set.

IBM_DB::fetch_assoc — Returns an array, indexed by column name,
representing a row in a result set

Description

array IBM_DB::fetch_assoc ( resource stmt [, int row_number] )

Returns an array, indexed by column name, representing a row in a result set.

Parameters

stmt

A valid stmt resource containing a result set.

row_number

Requests a specific 1-indexed row from the result set. Passing this parameter results in a
Ruby warning if the result set uses a forward-only cursor.

Return Values

Returns an associative array with column values indexed by the column name
representing the next or requested row in the result set. Returns FALSE if there are no
rows left in the result set, or if the
row requested by row_number does not exist in the result set.

IBM_DB::fetch_both — Returns an array, indexed by both column name
and position, representing a row in a result set

Description

array IBM_DB::fetch_both ( resource stmt [, int row_number] )

Returns an array, indexed by both column name and position, representing a
row in a result set. Note that the row
returned by IBM_DB::fetch_both() requires more memory than the
single-indexed arrays returned by IBM_DB::fetch_assoc() or
IBM_DB::fetch_array().

Parameters

stmt

A valid stmt resource containing a result set.

row_number

Requests a specific 1-indexed row from the result set. Passing this parameter results in a
Ruby warning if the result set uses a forward-only cursor.

Return Values

Returns an associative array with column values indexed by both the column
name and 0-indexed column number. The array represents the next or
requested row in the result set. Returns
FALSE if there are no rows left in the result set, or if the row requested by
row_number does not exist in the result
set.

IBM_DB::fetch_object — Returns an object with properties representing
columns in the fetched row

Description

object IBM_DB::fetch_object ( resource stmt [, int row_number] )

Returns an object in which each property represents a column returned in
the row fetched from a result set.

Parameters

stmt

A valid stmt resource containing a result set.

row_number

Requests a specific 1-indexed row from the result set. Passing this parameter results in a
Ruby warning if the result set uses a forward-only cursor.

Return Values

Returns an object representing a single row in the result set. The properties of the object map
to the names of the columns in the result set.

The IBM DB2, Cloudscape, and Apache Derby database servers typically fold
column names to upper-case, so the object properties will reflect that
case.

If your SELECT statement calls a scalar function to modify the value of a
column, the database servers return the column number as the name of the
column in the result set. If you prefer a
more descriptive column name and object property, you can use the AS clause
to assign a name to the column in the result set.

IBM_DB::fetch_row — Sets the result
set pointer to the next row or requested row

Description

bool IBM_DB::fetch_row ( resource stmt [, int row_number] )

Use IBM_DB::fetch_row() to iterate through a result set, or to point to a specific row in
a result set if you requested a
scrollable cursor.

To retrieve individual fields from the result set, call the IBM_DB::result()
function. Rather than calling IBM_DB::fetch_row() and IBM_DB::result(),
most applications will call one of IBM_DB::fetch_assoc(),
IBM_DB::fetch_both(), or IBM_DB::fetch_array() to advance the result set pointer and return a complete row
as an array.

Parameters

stmt

A valid stmt resource.

row_number

With scrollable cursors, you can request a specific row number in the result set. Row numbering
is 1-indexed.

Return Values

Returns TRUE if the requested row exists in the result set. Returns FALSE if the requested
row does not exist in the result set.

Return Values

IBM_DB::field_width — Returns the width of the current value of the
indicated column in a result set

Description

int IBM_DB::field_width ( resource stmt, mixed column )

Returns the width of the current value of the indicated column in a result set. This is the maximum width of the
column for a fixed-length data type, or the actual width of the column for
a variable-length data type.

Parameters

stmt

Specifies a statement resource containing a result set.

column

Specifies the column in the result set. This can either be an integer representing the
0-indexed position of the column, or a string containing the name of the column.

Return Values

Returns an integer containing the width of the specified character or
binary data type column in a result set.
If the specified column does not exist in the result set, IBM_DB::field_width() returns
FALSE.

Description

bool IBM_DB::free_result ( resource stmt )

Frees the system and database resources that are associated with a result set. These resources are freed
implicitly when a script finishes, but you can call IBM_DB::free_result()
to explicitly free the result set
resources before the end of the script.

Parameters

stmt

A valid statement resource.

Return Values

Description

bool IBM_DB::free_stmt ( resource stmt )

Frees the system and database resources that are associated with a
statement resource. These resources are freed implicitly when a script
finishes, but you can call IBM_DB::free_stmt() to explicitly free the
statement resources before the end of the script.

Parameters

stmt

A valid statement resource.

Return Values

Returns TRUE on success or FALSE on failure.

DEPRECATED

IBM_DB::get_last_serial_value — Gets the last inserted serial value
from IDS

Description

string IBM_DB::get_last_serial_value ( resource stmt )

Returns a string, that is the last inserted value for a serial column for
IDS. The last inserted value could be auto-generated or entered explicitly
by the user This function is valid for IDS (Informix Dynamic Server only)

Parameters

stmt

A valid statement resource.

Return Values

Returns a string representation of last inserted serial value on a
successful call. Returns FALSE on failure.

Return Values

IBM_DB::next_result — Requests the next result set from a stored procedure

Description

resource IBM_DB::next_result ( resource stmt )

A stored procedure can return zero or more result sets. While you handle the first result set in exactly the same way you would
handle the results returned by a simple SELECT statement, to fetch the
second and subsequent result sets from a
stored procedure you must call the IBM_DB::next_result() function and
return the result to a uniquely named
Ruby variable.

Parameters

stmt

A prepared statement returned from IBM_DB::exec() or IBM_DB::execute().

Return Values

Returns a new statement resource containing the next result set if the stored procedure returned
another result set. Returns FALSE if the
stored procedure did not return another result set.

IBM_DB::num_fields — Returns the number of fields contained in a result set

Description

int IBM_DB::num_fields ( resource stmt )

Returns the number of fields contained in a result set. This is most useful for handling
the result sets returned by dynamically
generated queries, or for result sets
returned by stored procedures, where your
application cannot otherwise know how to retrieve and use the results.

Parameters

stmt

A valid statement resource containing a result set.

Return Values

Returns an integer value representing the number of fields in the result set associated with the specified
statement resource. Returns FALSE if the statement resource is not a valid
input value.

IBM_DB::num_rows — Returns the number of rows affected by an SQL
statement

Description

int IBM_DB::num_rows ( resource stmt )

Returns the number of rows deleted, inserted, or updated by an SQL
statement.

To determine the number of rows that will be returned by a SELECT
statement, issue SELECT COUNT(*) with the same predicates as your intended
SELECT statement and retrieve the value. If your application logic checks
the number of rows returned by a SELECT statement and branches if the
number of rows is 0, consider modifying your application to attempt to
return the first row with one of IBM_DB::fetch_assoc(),
IBM_DB::fetch_both(), IBM_DB::fetch_array(), or IBM_DB::fetch_row(), and
branch if the fetch function returns FALSE.

Note: If you issue a SELECT statement using a scrollable cursor,
IBM_DB::num_rows() returns the number of rows returned by the SELECT
statement. However, the overhead associated with scrollable cursors
significantly degrades the performance of your application, so if this is
the only reason you are considering using scrollable cursors, you should
use a forward-only cursor and either call SELECT COUNT(*) or rely on the
boolean return value of the fetch functions to achieve the equivalent
functionality with much better performance.

Parameters

stmt

A valid stmt resource containing a result set.

Return Values

Returns the number of rows affected by the last SQL statement issued by the
specified statement handle.

Calling IBM_DB::close() on a persistent connection always returns TRUE, but
the underlying DB2 client connection remains open and waiting to serve the
next matching IBM_DB::pconnect() request.

Parameters

database

The database alias in the DB2 client catalog.

username

The username with which you are connecting to the database.

password

The password with which you are connecting to the database.

options

An associative array of connection options that affect the behavior of the connection,
where valid array keys include:
autocommit
Passing the DB2_AUTOCOMMIT_ON value turns autocommit on for this connection handle.
Passing the DB2_AUTOCOMMIT_OFF value turns autocommit off for this connection handle.
DB2_ATTR_CASE
Passing the DB2_CASE_NATURAL value specifies that column names are returned in natural case.
Passing the DB2_CASE_LOWER value specifies that column names are returned in lower case.
Passing the DB2_CASE_UPPER value specifies that column names are returned in upper case.
CURSOR
Passing the SQL_SCROLL_FORWARD_ONLY value specifies a forward-only cursor for a statement resource.
This is the default cursor type and is supported on all database servers.
Passing the SQL_CURSOR_KEYSET_DRIVEN value specifies a scrollable cursor for a statement resource.
This mode enables random access to rows in a result set, but currently is supported only
by IBM DB2 Universal Database.

Return Values

Returns a connection handle resource if the connection attempt is
successful. IBM_DB::pconnect() tries to reuse an existing connection
resource that exactly matches the database, username, and password
parameters. If the connection attempt fails, IBM_DB::pconnect() returns
FALSE.

Description

IBM_DB::prepare() creates a prepared SQL statement which can include 0 or
more parameter markers (? characters) representing parameters for input,
output, or input/output. You can pass parameters to the prepared statement
using IBM_DB::bind_param(), or for input values only, as an array passed to
IBM_DB::execute().

There are three main advantages to using prepared statements in your
application:

* Performance: when you prepare a statement, the database server creates an optimized access plan
for retrieving data with that statement. Subsequently issuing the prepared statement with
IBM_DB::execute() enables the statements to reuse that access plan and avoids the overhead of dynamically
creating a new access plan for every statement you issue.
* Security: when you prepare a statement, you can include parameter markers for input values.
When you execute a prepared statement with input values for placeholders, the database server checks
each input value to ensure that the type matches the column definition or parameter definition.
* Advanced functionality: Parameter markers not only enable you to pass input values to prepared
SQL statements, they also enable you to retrieve OUT and INOUT parameters from stored procedures
using IBM_DB::bind_param().

Parameters

connection

A valid database connection resource variable as returned from IBM_DB::connect() or IBM_DB::pconnect().

statement

An SQL statement, optionally containing one or more parameter markers..

options

An associative array containing statement options. You can use this parameter to request a
scrollable cursor on database servers that support this functionality.
cursor
Passing the SQL_SCROLL_FORWARD_ONLY value requests a forward-only cursor for this SQL statement.
This is the default type of cursor, and it is supported by all database servers. It is also
much faster than a scrollable cursor.
Passing the SQL_CURSOR_KEYSET_DRIVEN value requests a scrollable cursor for this SQL statement.
This type of cursor enables you to fetch rows non-sequentially from the database server.
However, it is only supported by DB2 servers, and is much slower than forward-only cursors.

Return Values

Returns a statement resource if the SQL statement was successfully parsed
and prepared by the database server. Returns FALSE if the database server
returned an error. You can determine which error was returned by calling
IBM_DB::stmt_error() or IBM_DB::stmt_errormsg().

Description

mixed IBM_DB::result ( resource stmt, mixed column )

Use IBM_DB::result() to return the value of a specified column in the
current row of a result set. You must
call IBM_DB::fetch_row() before calling IBM_DB::result() to set the
location of the result set pointer.

Parameters

stmt

A valid stmt resource.

column

Either an integer mapping to the 0-indexed field in the result set, or a string matching the name of the column.

Return Values

Returns the value of the requested field if the field exists in the result set. Returns NULL if the field does
not exist, and issues a warning.

Description

bool IBM_DB::rollback ( resource connection )

Rolls back an in-progress transaction on the specified connection resource
and begins a new transaction. Ruby applications normally default to
AUTOCOMMIT mode, so IBM_DB::rollback() normally has no effect unless
AUTOCOMMIT has been turned off for the connection resource.

Note: If the specified connection resource is a persistent
connection, all transactions in progress for all applications using that
persistent connection will be rolled back. For this reason, persistent
connections are not recommended for use in applications that require
transactions.

Parameters

connection

A valid database connection resource variable as returned from IBM_DB::connect() or IBM_DB::pconnect().

Return Values

IBM_DB::server_info — Returns an object with properties that describe
the DB2 database server

Description

object IBM_DB::server_info ( resource connection )

This function returns a read-only object with information about the IBM
DB2, Cloudscape, or Apache Derby database server. The following table lists
the database server properties:

Table 1. Database server properties

Property name:

Description (Return type)

DBMS_NAME:

The name of the database server to which you are connected. For DB2 servers
this is a combination of DB2 followed by the operating system on which the
database server is running. (string)

DBMS_VER:

The version of the database server, in the form of a string
"MM.mm.uuuu" where MM is the major version, mm is the minor
version, and uuuu is the update. For example, "08.02.0001"
represents major version 8, minor version 2, update 1. (string)

DB_CODEPAGE:

The code page of the database to which you are connected. (int)

DB_NAME:

The name of the database to which you are connected. (string)

DFT_ISOLATION:

The default transaction isolation level supported by the server: (string)

UR:

Uncommitted read: changes are immediately visible by all concurrent
transactions.

CS:

Cursor stability: a row read by one transaction can be altered and
committed by a second concurrent transaction.

RS:

Read stability: a transaction can add or remove rows matching a search
condition or a pending transaction.

RR:

Repeatable read: data affected by pending transaction is not available to
other transactions.

NC:

No commit: any changes are visible at the
end of a successful operation. Explicit commits and rollbacks are not
allowed.

IDENTIFIER_QUOTE_CHAR:

The character used to delimit an identifier. (string)

INST_NAME:

The instance on the database server that contains the database. (string)

ISOLATION_OPTION:

An array of the isolation options supported by the database server. The
isolation options are described in the DFT_ISOLATION property. (array)

KEYWORDS:

An array of the keywords reserved by the database server. (array)

LIKE_ESCAPE_CLAUSE:

TRUE if the database server supports the use of % and _ wildcard
characters. FALSE if the database server does not support these wildcard
characters. (bool)

MAX_COL_NAME_LEN:

Maximum length of a column name supported by the database server, expressed
in bytes. (int)

MAX_IDENTIFIER_LEN:

Maximum length of an SQL identifier supported by the database server,
expressed in characters. (int)

MAX_INDEX_SIZE:

Maximum size of columns combined in an
index supported by the database server, expressed in bytes. (int)

MAX_PROC_NAME_LEN:

Maximum length of a procedure name supported by the database server,
expressed in bytes. (int)

MAX_ROW_SIZE:

Maximum length of a row in a base table supported by the database server,
expressed in bytes. (int)

MAX_SCHEMA_NAME_LEN:

Maximum length of a schema name supported by the database server, expressed
in bytes. (int)

MAX_STATEMENT_LEN:

Maximum length of an SQL statement supported by the database server,
expressed in bytes. (int)

MAX_TABLE_NAME_LEN:

Maximum length of a table name supported by the database server, expressed
in bytes. (bool)

NON_NULLABLE_COLUMNS:

TRUE if the database server supports columns that can be defined as NOT NULL,
FALSE if the database server does not support columns defined as NOT NULL. (bool)

PROCEDURES:

TRUE if the database server supports the use of the CALL statement to call
stored procedures, FALSE if the database
server does not support the CALL statement. (bool)

SPECIAL_CHARS:

A string containing all of the characters other than a-Z, 0-9, and
underscore that can be used in an identifier name. (string)

SQL_CONFORMANCE:

The level of conformance to the ANSI/ISO SQL-92 specification offered by
the database server: (string)

Description

Returns a result set listing the unique
row identifier columns for a table.

Parameters

connection

A valid connection to an IBM DB2, Cloudscape, or Apache Derby database.

qualifier

A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string.

schema

The schema which contains the tables.

table_name

The name of the table.

scope

Integer value representing the minimum duration for which the unique row identifier is valid. This can be one of the following values:
0: Row identifier is valid only while the cursor is positioned on the row. (SQL_SCOPE_CURROW)
1: Row identifier is valid for the duration of the transaction. (SQL_SCOPE_TRANSACTION)
2: Row identifier is valid for the duration of the connection. (SQL_SCOPE_SESSION)

Return Values

Returns a statement resource with a result set containing rows with unique row
identifier information for a table. The rows are composed of the following
columns:

Column name:

Description

SCOPE:

Integer value representing the minimum duration for which the unique row
identifier is valid.

0: Row identifier is valid only while the cursor is positioned on the row.
(SQL_SCOPE_CURROW)

1: Row identifier is valid for the duration of the transaction.
(SQL_SCOPE_TRANSACTION)

2: Row identifier is valid for the duration of the connection.
(SQL_SCOPE_SESSION)

COLUMN_NAME:

Name of the unique column.

DATA_TYPE:

SQL data type for the column.

TYPE_NAME:

Character string representation of the SQL data type for the column.

COLUMN_SIZE:

An integer value representing the size of the column.

BUFFER_LENGTH:

Maximum number of bytes necessary to store data from this column.

DECIMAL_DIGITS:

The scale of the column, or NULL where scale is not applicable.

NUM_PREC_RADIX:

An integer value of either 10 (representing an exact numeric data type),2
(representing an approximate numeric data type), or NULL (representing a
data type for which radix is not applicable).

Description

Returns a result set listing the unique
row identifier columns for a table.

Parameters

connection

A valid connection to an IBM DB2, Cloudscape, or Apache Derby database.

qualifier

A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string.

schema

The schema which contains the tables.

table_name

The name of the table.

scope

Integer value representing the minimum duration for which the unique row identifier is valid. This can be one of the following values:
0: Row identifier is valid only while the cursor is positioned on the row. (SQL_SCOPE_CURROW)
1: Row identifier is valid for the duration of the transaction. (SQL_SCOPE_TRANSACTION)
2: Row identifier is valid for the duration of the connection. (SQL_SCOPE_SESSION)

Return Values

Returns a statement resource with a result set containing rows with unique row
identifier information for a table. The rows are composed of the following
columns:

Column name:

Description

SCOPE:

Integer value representing the minimum duration for which the unique row
identifier is valid.

0: Row identifier is valid only while the cursor is positioned on the row.
(SQL_SCOPE_CURROW)

1: Row identifier is valid for the duration of the transaction.
(SQL_SCOPE_TRANSACTION)

2: Row identifier is valid for the duration of the connection.
(SQL_SCOPE_SESSION)

COLUMN_NAME:

Name of the unique column.

DATA_TYPE:

SQL data type for the column.

TYPE_NAME:

Character string representation of the SQL data type for the column.

COLUMN_SIZE:

An integer value representing the size of the column.

BUFFER_LENGTH:

Maximum number of bytes necessary to store data from this column.

DECIMAL_DIGITS:

The scale of the column, or NULL where scale is not applicable.

NUM_PREC_RADIX:

An integer value of either 10 (representing an exact numeric data type),2
(representing an approximate numeric data type), or NULL (representing a
data type for which radix is not applicable).

Parameters

A valid connection to an IBM DB2, Cloudscape, or Apache Derby database.

qualifier

A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string.

schema

The schema that contains the targeted table. If this parameter is NULL, the statistics and indexes are
returned for the schema of the current user.

table_name

The name of the table.

unique

An boolean value representing the type of index information to return.
False Return only the information for unique indexes on the table.
True Return the information for all indexes on the table.

Return Values

Returns a statement resource with a result set containing rows describing the statistics and indexes for the base tables matching the specified parameters.
The rows are composed of the following columns:

Column name:

Description

TABLE_CAT:

The catalog that contains the table. The value is NULL if this table does
not have catalogs.

TABLE_SCHEM:

Name of the schema that contains the table.

TABLE_NAME:

Name of the table.

NON_UNIQUE:

An integer value representing whether the index prohibits unique values, or
whether the row represents statistics on
the table itself:

The row contains information about a type of index that is neither
clustered nor hashed.

ORDINAL_POSITION:

The 1-indexed position of the column in the index. NULL if the row contains
statistics information about the table
itself.

COLUMN_NAME:

The name of the column in the index. NULL if the row contains statistics information about the table
itself.

ASC_OR_DESC:

A if the column is sorted in ascending order, D if the column is sorted in
descending order, NULL if the row contains statistics information about the table
itself.

CARDINALITY:

If the row contains information about an index, this column contains an
integer value representing the number of unique values in the index. If the
row contains information about the table itself, this column contains an
integer value representing the number of rows in the table.

PAGES:

If the row contains information about an index, this column contains an
integer value representing the number of pages used to store the index. If
the row contains information about the table itself, this column contains
an integer value representing the number of pages used to store the table.

IBM_DB::stmt_error — Returns a string containing the SQLSTATE
returned by an SQL statement

Description

string IBM_DB::stmt_error ( [resource stmt] )

Returns a string containing the SQLSTATE value returned by an SQL
statement.

If you do not pass a statement resource as an argument to
IBM_DB::stmt_error(), the driver returns the SQLSTATE value associated with
the last attempt to return a statement resource, for example, from
IBM_DB::prepare() or IBM_DB::exec().

To learn what the SQLSTATE value means, you can issue the following command
at a DB2 Command Line Processor prompt: db2 ’? sqlstate-value’.
You can also call IBM_DB::stmt_errormsg() to retrieve an explicit error
message and the associated SQLCODE value.

Parameters

Return Values

Description

string IBM_DB::stmt_errormsg ( [resource stmt] )

Returns a string containing the last SQL statement error message.

If you do not pass a statement resource as an argument to
IBM_DB::stmt_errormsg(), the driver returns the error message associated
with the last attempt to return a statement resource, for example, from
IBM_DB::prepare() or IBM_DB::exec().

Parameters

stmt

A valid statement resource.

Return Values

Returns a string containing the error message and SQLCODE value for the
last error that occurred issuing an SQL statement.