SQLSetConnectAttr() sets connection attributes for a particular connection.
SQLRETURN SQLSetConnectAttr (SQLHDBC hdbc, SQLINTEGER fAttr, SQLPOINTER vParam, SQLINTEGER sLen);
Data type | Argument | Use | Description |
---|---|---|---|
SQLHDBC | hdbc | Input | Connection handle. |
SQLINTEGER | fAttr | Input | Connect attribute to set, refer to Table 2 for more information. |
SQLPOINTER | vParam | Input | Value associated with fAttr. Depending on the option, this can be a pointer to a 32-bit integer value, or a character string. |
SQLINTEGER | sLen | Input | Length of input value, if it is a character string; otherwise, unused. |
All connection and statement options set through the SQLSetConnectAttr() persist until SQLFreeConnect() is called or the next SQLSetConnectAttr() call.
fAttr | Contents |
---|---|
SQL_2ND_LEVEL_TEXT | A 32-bit integer value:
|
SQL_ATTR_AUTOCOMMIT | A 32-bit value that sets the commit behavior
for the connection. The following are possible values:
|
SQL_ATTR_COMMIT |
A 32-bit value that sets the transaction-isolation
level for the current connection referenced by hdbc. The following
values are accepted by DB2® UDB CLI, but each server might only support some
of these isolation levels:
In IBM® terminology,
For a detailed explanation of isolation levels, refer to the IBM DB2 SQL Reference. The SQL_ATTR_COMMIT attribute should be set before the SQLConnect(). If the value is changed after the connection has been established, and the connection is to a remote data source, the change does not take effect until the next successful SQLConnect() for the connection handle. |
SQL_ATTR_DATE_FMT | A 32-bit integer value:
|
SQL_ATTR_DATE_SEP | A 32-bit integer value:
|
SQL_ATTR_DBC_DEFAULT_LIB | A character value that indicates the default library that is used for resolving unqualified file references. This is not valid if the connection is using system naming mode. |
SQL_ATTR_DBC_SYS_NAMING | A 32-bit integer value:
|
SQL_ATTR_DECIMAL_SEP | A 32-bit integer value:
|
SQL_ATTR_EXTENDED_COL_INFO | A 32-bit integer value:
|
SQL_ATTR_HEX_LITERALS | A 32-bit integer value:
|
SQL_ATTR_MAX_PRECISION | An integer constant that is the maximum precision (length) that should be returned for the result data types. The value can be 31 or 63. |
SQL_ATTR_MAX_SCALE | An integer constant that is the maximum scale (number of decimal positions to the right of the decimal point) that should be returned for the result data types. The value can range from 0 to the maximum precision. |
SQL_ATTR_MIN_DIVIDE_SCALE | Specify the minimum divide scale (number of decimal positions to the right of the decimal point) that should be returned for the result data types resulting from a divide operation. The value can range from 0 to 9, not to exceed the maximum scale. If 0 is specified, minimum divide scale is not used. |
SQL_ATTR_QUERY_OPTIMIZE_GOAL |
A 32-bit integer value that tells the optimizer to behave
in a specified way when processing a query:
|
SQL_ATTR_TIME_FMT | A 32-bit integer value:
|
SQL_ATTR_TIME_SEP | A 32-bit integer value:
|
SQL_ATTR_TXN_EXTERNAL |
A 32-bit integer value that must be SQL_TRUE to enable the use of XA transaction setting in the CLI connection. SQL_ATTR_TXN_EXTERNAL must be set to SQL_TRUE to use the XA transaction options by the SQL_ATTR_TXN_INFO connection attribute. The default is SQL_FALSE, which is not to enable XA transaction support. However, as soon as transaction support is enabled for the connection, it cannot be disabled. (Attempting to set SQL_ATTR_TXN_EXTERNAL to SQL_FALSE results in a CLI error.) Further information as well as an example of use of the SQL_ATTR_TXN_EXTERNAL connection attribute can be found in Example: Use the CLI XA transaction connection attributes. |
SQL_ATTR_TXN_INFO |
A 32-bit integer value:
Use of this connection attribute requires the user to be running in server mode. Keep in mind, a user cannot toggle between a non-server mode and server mode environment. The input argument vParam must point to a TXN_STRUCT object. This structure can be found in the header file QSYSINC/h.SQLCLI. The xa_info argument for the xa_open XA API must include the THDCTL=C keyword and value when using CLI with XA transactions. See XA transaction support for commitment control in the Commitment control topic for more information about XA transactions. See XA API for more information. See Example: Use the CLI XA transaction connection attributes for more information and an example that shows how you can use the SQL_ATTR_TXN_INFO connection attribute. When running XA calls through CLI, the return codes from CLI reflect the XA return code specifications. These values can be found in the XA specification documentation, as well as in the XA.h include file. Note that the return code values that are listed in the XA include file take precedence over the CLI return code values when calling XA through this connection attribute. |
SQL_ATTR_UCS2 | A 32-bit integer value:
|
SQL_SAVEPOINT_NAME | A character value that indicates the savepoint name to be used by SQLEndTran() on the functions SQL_SAVEPOINT_NAME_ROLLBACK or SQL_SAVEPOINT_NAME_RELEASE. |
SQLSTATE | Description | Explanation |
---|---|---|
HY001 | Memory allocation failure | The driver is unable to allocate memory required to support the processing or completion of the function. |
HY009 | Argument value that is not valid | Given the fAttr value, a value that
is not valid is specified for the argument vParam. An fAttr that is not valid value is specified. |