DB2 CLI manages the transfer and any required conversion of data between the application and DB2 Everyplace. Before the data transfer actually takes place, the source, target, or both data types are indicated when calling SQLBindParameter(), SQLBindCol(), or SQLGetData(). These functions use the symbolic names (such as SQL_CHAR and SQL_C_CHAR) to identify the data types involved.
For example, to bind a parameter marker that corresponds to an SQL data type of SQL_VARCHAR to an application's C buffer type of long integer, the appropriate SQLBindParameter() call would be:
SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 0, 0, long_ptr, 0, NULL);
Table 86 shows the supported data conversions between C and SQL data types. The first column in Table 86 contains the SQL data type. The remaining columns represent the C data types. If the C data type column contains:
Limits on precision and scale and truncation and rounding rules for type conversions follow SQL syntax rules.
Table 86. Supported data conversions
SQL data type | Default conversion | Other supported conversions |
---|---|---|
BLOB | SQL C BINARY | SQL C CHAR |
CHAR | SQL C CHAR |
SQL C LONG SQL C SHORT SQL C TINYINT SQL C TYPE DATE SQL C TYPE TIME SQL C BINARY SQL C BIT SQL C TYPE TIMESTAMP |
DATE | SQL C TYPE DATE | SQL C CHAR |
DECIMAL | SQL C CHAR |
SQL C LONG SQL C SHORT SQL C TINYINT SQL C BIT |
INTEGER | SQL C LONG |
SQL C CHAR SQL C SHORT SQL C TINYINT SQL C FLOAT SQL C DOUBLE SQL C BIT |
SMALLINT | SQL C SHORT |
SQL C CHAR SQL C LONG SQL C TINYINT SQL C FLOAT SQL C DOUBLE SQL C BIT |
TIME | SQL C TYPE TIME | SQL C CHAR |
TIMESTAMP | SQL C TYPE TIMESTAMP | SQL C CHAR |
VARCHAR | SQL C CHAR |
SQL C LONG SQL C SHORT SQL C TINYINT SQL C TYPE DATE SQL C TYPE TIME SQL C BINARY SQL C BIT SQL C TYPE TIMESTAMP |
Related reference