Functions for setting and retrieving environment, connection, and statement attributes

Db2 ODBC provides functions that let you set or retrieve a subset of environment, connection, and statement attributes.

Environments, connections, and statements each have a defined set of attributes (or options). You can query all these attributes, but you can change only some of these attributes from their default values. When you change attribute values, you change the behavior of Db2 ODBC.

The attributes that you can change are listed in the detailed descriptions of the set-attribute functions listed below:
  • SQLSetEnvAttr() - Set environment attributes
  • SQLSetConnectAttr() - Set connection attributes
  • SQLSetStmtAttr() - Set statement attributes
  • SQLSetColAttr() - Set column attributes

Read-only attributes (if any exist) are listed with the detailed function descriptions of the get-attribute functions.

Usually you write applications that use default attribute settings; however, these defaults are not always suitable for particular users of your application. Db2 ODBC provides two points at which users of your application can change default values of attributes at run time. Users specify attribute values either from an interface that uses the SQLDriverConnect() connection string or they can specify values in the Db2 ODBC initialization file.

The Db2 ODBC initialization file specifies the default attribute values for all Db2 ODBC applications. If an application does not provide users with an interface to the SQLDriverConnect() connection string, users can change default attribute values through the initialization file only. Attribute values that are specified with SQLDriverConnect() override the values that are set in the Db2 ODBC initialization file for any particular connection.

Important: The initialization file and connection string are intended for user tuning. Application developers should use the appropriate set-attribute functions to change attribute values. When you use set-attribute functions to set attribute values, the value that you specify overrides the initialization file value and the SQLDriverConnect() connection string value for that attribute.

The following figure shows how you set and retrieve attribute values within a basic connect scenario.

Figure 1. Setting and retrieving attributes
Begin figure summary. This figure is a flowchart that depicts the functions that are used in a basic connection scenario. Detailed description available.