SQLSetConnectOption - Set connection option

Purpose

Start of changeSQLSetConnectOption() has been deprecated and replaced with SQLSetConnectAttr(). Although this version of DB2® UDB CLI continues to support SQLSetConnectOption(), it is recommended that you begin using SQLSetConnectAttr() in your DB2 UDB CLI programs so that they conform to the latest standards.End of change

SQLSetConnectOption() sets connection attributes for a particular connection.

Syntax

SQLRETURN SQLSetConnectOption  (SQLHDBC hdbc,
                                SQLSMALLINT fOption,
                                SQLPOINTER  vParam);

Function arguments

Table 1. SQLSetConnectOption arguments
Data type Argument Use Description
SQLHDBC hdbc Input Connection handle.
SQLPOINTER vParam Input Value associated with fOption. Depending on the option, this can be a pointer to a 32-bit integer value, or a character string.
SQLSMALLINT fOption Input Connect option to set, refer to Table 2 for more information.

Usage

Start of changeThe SQLSetConnectOption() provides many of the same attribute functions as SQLSetConnectAttr() prior to V5R3. However, SQLSetConnectOption() has since been deprecated, and support for all new attribute functions has gone into SQLSetConnectAttr(). Users should migrate to the nondeprecated interface.End of change

All connection and statement options set through the SQLSetConnectOption() persist until SQLFreeConnect() is called or the next SQLSetConnectOption() call.

The format of information set through vParam depends on the specified fOption. The option information can be either a 32-bit integer or a pointer to a null-terminated character string.

Refer to Table 2 for the appropriate connect options.

Note: Start of changeBecause SQLSetConnectOption() has been deprecated, not all the options listed in the table are supported.End of change

Return codes

Diagnostics

Table 2. SQLSetConnectOption SQLSTATEs
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 fOption value, a value that is not valid is specified for the argument vParam.

A fOption value that is not valid is specified.

HYC00 Driver not capable The specified fOption is not supported by DB2 UDB CLI or the server.

Given specified fOptionvalue, the value specified for the argument vParam is not supported.

Related reference
SQLSetConnectAttr - Set a connection attribute