C to SQL data conversion

To convert C data types to SQL data types, you need to know the arguments: fSqlType and pcbValue. The SQLSTATE for each conversion outcome is returned.

For each C data conversion type a table lists conversion information. Each column in these tables lists the following information:
  • The first column of the table lists the legal input values of the fSqlType argument in SQLBindParameter().
  • The second column lists the outcomes of a test, often using the length, in bytes, of the parameter data as specified in the pcbValue argument in SQLBindParameter(), which the driver performs to determine if it can convert the data.
  • The third column lists the SQLSTATE returned for each outcome by SQLExecDirect() or SQLExecute().
    Important: Data is sent to the data source only if the SQLSTATE is 00000 (success).

The tables list the conversions defined by ODBC to be valid for a given SQL data type.

If the fSqlType argument in SQLBindParameter() contains a value not shown in the table for a given C data type, SQLSTATE 07006 is returned (Restricted data type attribute violation).

If the fSqlType argument contains a value shown in the table but which specifies a conversion not supported by the driver, SQLBindParameter() returns SQLSTATE HYC00 (Driver not capable).

If the rgbValue and pcbValue arguments specified in SQLBindParameter() are both null pointers, that function returns SQLSTATE HY009 (Invalid argument value).

Data length
The total length in bytes of the data after it has been converted to the specified SQL data type (excluding the nul-termination character if the data was converted to a string). This is true even if data is truncated before it is sent to the data source.
Column length
The maximum number of bytes returned to the application when data is transferred to its default C data type. For character data, the length does not include the nul-termination character.
Display size
The maximum number of bytes needed to display data in character form.
Significant digits
The minus sign (if needed) and the digits to the left of the decimal point.