C data types that do not map to SQL data types

In addition to the data types that map to SQL data types, other C symbolic types are used for other function arguments, such as pointers and handles.

The following table shows both generic and ODBC data types used for these arguments.

Table 1. C data types and base C data types
Defined C type Base C type Typical usage
SQLPOINTER void * Pointers to storage for data and parameters.
SQLHENV long int (31-bit) or int (64-bit)1 Handle referencing environment information.
SQLHDBC long int (31-bit) or int (64-bit)1 Handle referencing data source connection information.
SQLHSTMT long int (31-bit) or int (64-bit)1 Handle referencing statement information.
SQLUSMALLINT unsigned short int Function input argument for unsigned short integer values.
SQLUINTEGER unsigned long int (31-bit) or unsigned int (64-bit)1 Function input argument for unsigned long integer values.
SQLLEN int Function input or output argument for 32-bit integer values.
SQLULEN unsigned int Function input or output argument for unsigned 32-bit integer values.
SQLRETURN short int Return code from Db2 ODBC functions.
SQLWCHAR wchar_t (31-bit) or unsigned short (64-bit)1 Data type for a Unicode UCS-2 character.
SQLWCHAR * wchar_t * (31-bit) or unsigned short * (64-bit)1 Pointer to storage for Unicode UCS-2 data.
Note:
  1. 31-bit is for 31-bit applications, and 64-bit is for 64 bit applications.

    In the 31-bit environment, long int and unsigned long int are each 32 bits. In the 64-bit environment, int and unsigned int are also each 32 bits. Therefore, the C types SQLHENV, SQLHDBC, SQLHSTMT, and SQLUINTEGER are each mapped to 32-bit fields regardless of the environment.

    In the 31-bit environment, wchar_t is 16 bits. In the 64-bit environment, unsigned short is also 16 bits. Therefore, the C type SQLWCHAR is mapped to a 16-bit field regardless of the environment.

    Pointers do not have the same size in a 64-bit environment as they do in a 31-bit environment. In the 31-bit environment, SQLWCHAR * is 32 bits long, and in the 64-bit environment, SQLWCHAR * is 64 bits long.