C to SQL conversion for numeric data

You can convert numeric C data types to SQL data types.

The numeric C data types are:
  • SQL_C_SHORT
  • SQL_C_LONG
  • SQL_C_BIGINT
  • SQL_C_FLOAT
  • SQL_C_DOUBLE
  • SQL_C_TINYINT
  • SQL_C_BIT
  • SQL_C_DECIMAL64
  • SQL_C_DECIMAL128

The following table shows information about converting numeric C data to SQL data.

Table 1. Conversion of numeric C data to SQL data
fSqlType Test SQLSTATE
  • SQL_DECIMAL
  • SQL_NUMERIC
  • SQL_SMALLINT
  • SQL_INTEGER
  • SQL_BIGINT
  • SQL_REAL
  • SQL_FLOAT
  • SQL_DOUBLE
  • SQL_DECFLOAT
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
SQL_CHAR SQL_VARCHAR Data converted without truncation. 000001
Conversion of data would result in loss of significant digits. 22003
Note:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.