C data types for CLI applications
You can use SQL data
types with Call Level Interface (CLI)
applications, the corresponding symbolic name of the CLI application,
and the default C symbolic name. A C symbolic name corresponds to
a C data type.
The following table lists the generic type definitions for each symbolic C type that is used in CLI applications.
- C symbolic data type
- This column contains C symbolic names, defined as integer values. These values are used in various function arguments to identify the C data type shown in the last column.
- C type
- This column contains C defined types, defined in
sqlcli.h
using a Ctypedef
statement. The values in this column should be used to declare all CLI related variables and arguments, in order to make the application more portable. See Table 3 for a list of additional symbolic data types used for function arguments. - Base C type
- This column is shown for reference only. All variables and arguments should be defined using the symbolic types in the previous column since the base C type is platform dependent. Some of the values are C structures that are described in Table 2.
C symbolic data type | C type | Base C type |
---|---|---|
SQL_C_BINARY | SQLCHAR | unsigned char |
SQL_C_BINARYXML | SQLCHAR | unsigned char |
SQL_C_BIT | SQLCHAR | unsigned char or char (Value 1 or 0) |
SQL_C_BLOB_LOCATOR a | SQLINTEGER | 32-bit integer |
SQL_C_CLOB_LOCATOR a | SQLINTEGER | 32-bit integer |
SQL_C_CHAR | SQLCHAR | unsigned char |
SQL_C_CURSORHANDLE | SQLINTEGER | 32-bit integer |
SQL_C_DBCHAR | SQLDBCHAR | wchar_t |
SQL_C_DBCLOB_LOCATOR | SQLINTEGER | 32-bit integer |
SQL_C_DECIMAL64 | SQLDECIMAL64 | see Table 2 |
SQL_C_DECIMAL128 | SQLDECIMAL128 | see Table 2 |
SQL_C_DOUBLE | SQLDOUBLE | double |
SQL_C_FLOAT | SQLREAL | float |
SQL_C_LONG | SQLINTEGER | 32-bit integer |
SQL_C_NUMERIC b | SQL_NUMERIC_STRUCT | see Table 2 |
SQL_C_SBIGINT | SQLBIGINT | 64-bit integer |
SQL_C_SHORT | SQLSMALLINT | 16-bit integer |
SQL_C_TINYINT | SQLSCHAR | signed char (Range -128 to 127) |
SQL_C_TYPE_DATE | DATE_STRUCT | see Table 2 |
SQL_C_TYPE_TIME | TIME_STRUCT | see Table 2 |
SQL_C_TYPE_TIMESTAMP | TIMESTAMP_STRUCT | see Table 2 |
SQL_C_TYPE_TIMESTAMP_EXT | TIMESTAMP_STRUCT_EXT | see Table 2 |
SQL_C_TYPE_TIMESTAMP_EXT_TZ | TIMESTAMP_STRUCT_EXT_TZ | see Table 2 |
SQL_C_UBIGINT | SQLUBIGINT | unsigned 64-bit integer |
SQL_C_ULONG | SQLUINTEGER | unsigned 32-bit integer |
SQL_C_USHORT | SQLUSMALLINT | unsigned 16-bit integer |
SQL_C_UTINYINT | SQLUCHAR | unsigned char |
SQL_C_WCHAR | SQLWCHAR | wchar_t |
SQL_C_TYPE_TIMESTAMP_EXT | TIMESTAMP_STRUCT_EXT | See Table 2 |
Note: SQL file reference data types (used
in embedded SQL) are not needed in CLI.
Note: You use the SQL_C_BINARYXML C data type with the binary XML data transmission
format, which is supported by Db2®
CLI
. The Db2 server
must also be at a level that supports the binary XML format.
|
C type | Generic structure | Windows structure |
---|---|---|
DATE_STRUCT | |
|
TIME_STRUCT | |
|
TIMESTAMP_STRUCT | |
|
TIMESTAMP_STRUCT_EXT |
|
(No Windows structure. Only a generic structure.) |
TIMESTAMP_STRUCT_EXT _TZ |
|
(No Windows structure. Only a generic structure.) |
SQLDECIMAL64 |
|
(No Windows structure. Only a generic structure.) |
SQLDECIMAL128 |
|
(No Windows structure. Only a generic structure.) |
SQL_NUMERIC_STRUCT | (No generic structure. Only a Windows structure.) | |
See Table 3 for more information about the SQLUSMALLINT
C data type.
|
As well as the data types that map to SQL data types,
there are also C symbolic types used for other function arguments
such as pointers and handles. Both the generic and ODBC data types
are shown in the following table.
Note: There are two kinds of drivers
that ship with the product: the CLI driver,
and the 64-bit ODBC driver. The 64-bit ODBC Driver handles the differences
with type definitions between various ODBC Managers.
Defined C type | Base C type | Typical usage |
---|---|---|
SQLPOINTER | void * | Pointer to storage for data and parameters. |
SQLHANDLE |
|
The handle that references all 4 types of handle information.
|
SQLHENV |
|
The handle that references environment information.
|
SQLHDBC |
|
The handle that references database connection information.
|
SQLHSTMT |
|
The handle that references statement information.
|
SQLUSMALLINT | unsigned 16-bit integer | The function input argument for unsigned short integer values. |
SQLUINTEGER | unsigned 32-bit integer | The function input argument for unsigned long integer values. |
SQLRETURN | 16-bit integer | The return code from CLI functions. |
SQLULEN |
|
|
SQLLEN |
|
|
SQLSETPOSIROW |
|
|