C-to-SQL data conversion examples

The examples show how HCL OneDB™ ODBC Driver converts C data to SQL data.

The following table illustrates how HCL OneDB ODBC Driver converts C data to SQL data. “\0” represents a null-termination byte. The null-termination byte is required only if the length of the data is SQL_NTS. For SQL_C_DATE, the numbers that are in the C Data Value column are the numbers that are stored in the fields of the DATE_STRUCT structure. For SQL_C_TIMESTAMP, the numbers that are in the C Data Value column are the numbers that are stored in the fields of the TIMESTAMP_STRUCT structure.
C data type C data value SQL data type Column length SQL data value SQLSTATE
SQL_C_CHAR tigers\0 SQL_CHAR 6 tigers N/A
SQL_C_CHAR tigers\0 SQL_CHAR 5 tiger 01004
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 8

(In addition to bytes for numbers, one byte is required for a sign and another for the decimal point.)

1234.56 N/A
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 7

(In addition to bytes for numbers, one byte is required for a sign and another for the decimal point.)

1234.5 01004
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 4 22003
SQL_C_FLOAT 1234.56 SQL_FLOAT not applicable 1234.56 N/A
SQL_C_FLOAT 1234.56 SQL_INTEGER not applicable 1234 01004
SQL_C_FLOAT 1234.56 SQL_TINYINT not applicable 22003
SQL_C_DATE 1992,12,31 SQL_CHAR 10 1992-12-31 N/A
SQL_C_DATE 1992,12,31 SQL_CHAR 9 22003
SQL_C_DATE 1992,12,31 SQL_TIMESTAMP not applicable 1992-12-31

00:00:00.0

N/A
SQL_C_TIMESTAMP 1992,12,31,

23,45,55,

120000000

SQL_CHAR 22 1992-12-31

23:45:55.12

N/A
SQL_C_TIMESTAMP 1992,12,31,

23,45,55,

120000000

SQL_CHAR 21 1992-12-31

23:45:55.1

01004
SQL_C_TIMESTAMP 1992,12,31,

23,45,55,

120000000

SQL_CHAR 18 22003