C to SQL data conversion examples

The C data types that you can convert to SQL data types are character, numeric, binary, double-byte, date, time, and timestamp data.

The following table shows example C to SQL data conversions and the SQLSTATE associated with these conversions.

Table 1. C to SQL data conversion examples
C data type C data Value SQL data type Column length SQL data value SQLSTATE
SQL_C_CHAR abcdef\0 SQL_CHAR 6 abcdef 000001
SQL_C_CHAR abcdef\0 SQL_CHAR 5 abcde 01004
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 6 1234.56 000001
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 5 1234.5 01004
SQL_C_CHAR 1234.56\0 SQL_DECIMAL 3 --- 22003
SQL_C_FLOAT 1234.56 SQL_FLOAT Not applicable 1234.56 000001
SQL_C_FLOAT 1234.56 SQL_INTEGER Not applicable 1234 01004
Note:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.