Functions for binding host variables to C types

You use the generic APIs SQLBindCol(), SQLBindParameter(), and SQLGetData() as the entry points to bind application variables in all encoding schemes. Db2 ODBC requires only a single entry point to functions that bind application variables.

The Db2 ODBC driver uses the following specifications to determine the encoding scheme of the character data in these functions:
  • The fCType argument value in SQLBindCol(), SQLBindParameter(), and SQLGetData().
  • The setting of the CURRENTAPPENSCH keyword in the Db2 ODBC initialization file, if the fCType argument value is not SQL_C_WCHAR.

    If fCType is SQL_C_WCHAR, the encoding scheme is Unicode UCS-2, regardless of the CURRENTAPPENSCH setting.

The following table summarizes how to set the CURRENTAPPENSCH keyword, declare application variables, and declare the fCType argument to bind application variables in each encoding scheme.

Table 1. Required values to bind application variables in each encoding scheme
Db2 ODBC elements EBCDIC Unicode UCS-2 Unicode UTF-8 ASCII
CURRENTAPPENSCH keyword setting EBCDIC (default) Not applicable UNICODE ASCII
Application variable C type definition SQLCHAR or SQLDBCHAR SQLWCHAR SQLCHAR SQLCHAR or SQLDBCHAR
fCType on SQLBindParameter(), SQLBindCol(), or SQLGetData() SQL_C_CHAR or SQL_C_DBCHAR SQL_C_WCHAR SQL_C_CHAR SQL_C_CHAR or SQL_C_DBCHAR

Requirement: You must use the symbolic C data type for the fCType argument that corresponds to the data type you use for application variables. For example, when you bind SQLCHAR application variables, you must specify the symbolic C data type SQL_C_CHAR for the fCType argument in your bind function call.