SQL-to-C data conversion examples

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

The following table illustrates how HCL OneDB ODBC Driver converts SQL data to C data. “\0” represents a null-termination byte ( “\0” represents a wide null termination character when the C data type is SQL_C_WCHAR). HCL OneDB ODBC Driver always null-terminates SQL_C_CHAR and SQL_C_WCHAR data. For the combination of SQL_DATE and SQL_C_TIMESTAMP, HCL OneDB ODBC Driver stores the numbers that are in the rgbValue column in the fields of the TIMESTAMP_STRUCT structure.

Six-column table that shows how HCL OneDB ODBC Driver converts SQL data to C data.

SQL data type SQL data value C data type cbValueMax rgbValue SQLSTATE
SQL_CHAR tigers SQL_C_CHAR 7 tigers\0 N/A
SQL_CHAR tigers SQL_C_CHAR 6 tiger\0 01004
SQL_CHAR tigers SQL_C_WCHAR 14 tigers\0 N/A
SQL_CHAR tigers SQL_C_WCHAR 12 tiger\0 01004
SQL_DECIMAL 1234.56 SQL_C_CHAR 8 1234.56\0 N/A
SQL_DECIMAL 1234.56 SQL_C_CHAR 5 1234\0 01004
SQL_DECIMAL 1234.56 SQL_C_CHAR 4 22003
SQL_DECIMAL 1234.56 SQL_C_WCHAR 16 1234.56\0 N/A
SQL_DECIMAL 1234.56 SQL_C_WCHAR 10 1234\0 01004
SQL_DECIMAL 1234.56 SQL_C_WCHAR 8 220023
SQL_DECIMAL 1234.56 SQL_C_FLOAT Ignored 1234.56 N/A
SQL_DECIMAL 1234.56 SQL_C_SSHORT Ignored 1234 01004
SQL_DECIMAL 1234.56 SQL_C_STINYINT Ignored 22003
SQL_DOUBLE 1.2345678 SQL_C_DOUBLE Ignored 1.234567 N/A
SQL_DOUBLE 1.2345678 SQL_C_FLOAT Ignored 1.234567 N/A
SQL_DOUBLE 1.2345678 SQL_C_STINYINT Ignored 1 N/A
SQL_DATE 1992-12-31 SQL_C_CHAR 11 1992-12-31\0 N/A
SQL_DATE 1992-12-31 SQL_C_CHAR 10 22003
SQL_DATE 1992-12-31 SQL_C_WCHAR 22 1992-12-31\0 N/A
SQL_DATE 1992-12-31 SQL_C_WCHAR 20 22003
SQL_DATE 1992-12-31 SQL_C_TIMESTAMP Ignored 1992,12,31,

0,0,0,0

N/A
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_CHAR 23 1992-12-31

23:45:55.12\0

N/A
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_CHAR 22 1992-12-31

23:45:55.1\0

01004
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_CHAR 18 22003
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_WCHAR 46 1992-12-31

23:45:55.12\0

N/A
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_WCHAR 44 1992-12-31

23:45:55.1\0

01004
SQL_TIMESTAMP 1992-12-31

23:45:55.12

SQL_C_WCHAR 36 22003
Important: The size of a wide character (wchar_t) is platform dependent. The previous examples are applicable to Windows™ where the size of wide characters is 2 bytes. On most UNIX™ platforms, wide characters are 4 bytes. On IBM AIX® versions lower than AIX5L, it is 2 bytes.