The identifiers for the numeric ODBC C data types are:
SQL_C_STINYINTSQL_C_SLONG
SQL_C_UTINYINTSQL_C_ULONG
SQL_C_TINYINTSQL_C_LONG
SQL_C_SSHORTSQL_C_FLOAT
SQL_C_USHORTSQL_C_DOUBLE
SQL_C_SHORTSQL_C_NUMERIC
SQL_C_SBIGINTSQL_C_UBIGINT
The following table shows the ODBC SQL data types to which numeric C data may be converted. For an explanation of the columns and terms in the table, see “Converting Data from C to SQL Data Types.”
SQL type identifier |
Test |
SQL- STATE |
SQL_CHAR SQL_VARCHAR SQL_LONGVARCHAR |
Number of digits <= Column byte length. Number of digits > Column byte length. |
n/a 22001 |
SQL_WCHAR SQL_WVARCHAR SQL_WLONGVARCHAR |
Number of characters <= Column character length. Number of characters > Column character length. |
n/a 22001 |
SQL_DECIMAL SQL_NUMERIC SQL_TINYINT SQL_SMALLINT SQL_INTEGER SQL_BIGINT |
Data converted without truncation or with truncated of fractional digits. Data converted with truncation of whole digits. |
n/a
|
SQL_REAL SQL_FLOAT SQL_DOUBLE |
Data is within the range of the data type to which the number is being converted. Data is outside the range of the data type to which the number is being converted. |
n/a 22003 |
SQL_BIT | Data is 0 or 1. Data is greater than 0, less than 2, and not equal to 1. Data is less than 0 or greater than or equal to 2. |
n/a
22001 22003 |
SQL_INTERVAL_YEAR [a] SQL_INTERVAL_MONTH [a] SQL_INTERVAL_DAY [a] SQL_INTERVAL_HOUR [a] SQL_INTERVAL_MINUTE [a] SQL_INTERVAL_SECOND [a] |
Data not truncated. Data truncated. |
n/a 22015 |
[a]These conversions are supported only for the exact numeric data types (SQL_C_STINYINT, SQL_C_UTINYINT, SQL_C_SSHORT, SQL_C_USHORT, SQL_C_SLONG, SQL_C_ULONG, or SQL_C_NUMERIC). They are not supported for the approximate numeric data types (SQL_C_FLOAT or SQL_C_DOUBLE). Exact numeric C data types cannot be converted to an interval SQL type whose interval precision is not a single field.
The driver ignores the length/indicator value when converting data from the numeric C data types and assumes that the size of the data buffer is the size of the numeric C data type. The length/indicator value is passed in the StrLen_or_Ind argument in SQLPutData and in the buffer specified with the StrLen_or_IndPtr argument in SQLBindParameter. The data buffer is specified with the DataPtr argument in SQLPutData and the ParameterValuePtr argument in SQLBindParameter.