SQL to C conversion for numeric data

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

The numeric SQL data types are:
  • SQL_DECIMAL
  • SQL_DECFLOAT
  • SQL_NUMERIC
  • SQL_SMALLINT
  • SQL_INTEGER
  • SQL_BIGINT
  • SQL_REAL
  • SQL_FLOAT
  • SQL_DOUBLE

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

Table 1. Conversion of numeric SQL data to C data
fCType Test rgbValue pcbValue SQLSTATE
  • SQL_C_CHAR
  • SQL_C_WCHAR
Display size < cbValueMax Data Data length (in bytes) 000001
Number of significant digits < cbValueMax Truncated data Data length (in bytes) 01004
Number of significant digits >= cbValueMax Untouched Data length (in bytes) 22003
  • 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
Data converted without truncation2 Data Size (in bytes) of the C data type 000001
Data converted with truncation, but without loss of significant digits2 Truncated data Size (in bytes) of the C data type 01004
Conversion of data would result in loss of significant digits2 Untouched Size (in bytes) of the C data type 22003
Notes:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.
  2. The value of cbValueMax is ignored for this conversion. The driver assumes that the size of rgbValue is the size of the C data type.