C to SQL conversion for character data
You can convert the C data types, SQL_C_CHAR and SQL_C_WCHAR, to SQL data types.
The data length for the SQL_C_WCHAR data type is the number of bytes of UCS-2 Unicode data.
The following table shows information about converting character C data to SQL data.
| fSqlType | Test | SQLSTATE |
|---|---|---|
|
Data length <= Column length | 000001 |
| Data length > Column length | 01004 | |
|
Data converted without truncation | 000001 |
| Data converted with truncation, but without loss of significant digits | 01004 | |
| Conversion of data would result in loss of significant digits | 22003 | |
| Data value is not a numeric value | 22005 | |
| SQL_BINARY SQL_VARBINARY SQL_LONGVARBINARY SQL_BLOB | (Data length) < Column length | N/A |
| (Data length) >= Column length | 01004 | |
| Data value is not a hexadecimal value | 22005 | |
| SQL_ROWID | Data length <= Column length | 000001 |
| Data length > Column length | 01004 | |
| SQL_TYPE_DATE | Data value is a valid date | 000001 |
| Data value is a valid timestamp2 | 000001 | |
| Data value is not a valid date or timestamp | 22008 | |
| SQL_TYPE_TIME | Data value is a valid time | 000001 |
| Data value is not a valid time or timestamp | 22008 | |
| Data value is a valid timestamp3 | 000001 | |
| SQL_TYPE_TIMESTAMP | Data value is a valid timestamp | 000001 |
| Data value is not a valid timestamp. | 22008 | |
| Data value is a valid timestamp; fractional seconds truncated | 01004 | |
| Data value is valid timestamp; time zone portion is nonzero. | 01004 | |
| SQL_TYPE_TIMESTAMP_WITH_TIMEZONE | Data value is a valid timestamp with time zone | 000001 |
| Data value is not a valid timestamp with time zone | 22008 | |
| Data value is a valid timestamp, and time zone fields are not specified4 | 000001 | |
| Data value is a valid timestamp with time zone; fractional seconds truncated | 01004 | |
|
Data length / 2 <= Column length | 000001 |
| Data length / 2 < Column length | 01004 | |
| SQL_XML | None | 000001 |
| Note:
|
||