SQL to C: Binary

The binary HCL OneDB™ ODBC Driver SQL data type is SQL_LONGVARBINARY.

The following table shows the HCL OneDB ODBC Driver C data types to which binary SQL data can be converted.

A four-column table that shows binary SQL data and the available HCL OneDB ODBC Driver C data type conversions.

fCType Test rgbValue pcbValue SQLSTATE
SQL_C_BINARY Length of data cbValueMax Data Length of data N/A
Length of data > cbValueMax Truncated data Length of data 01004
SQL_C_CHAR (Length of data) * 2 < cbValueMax Data Length of data N/A
(Length of data) * 2 cbValueMax Truncated data Length of data 01004

When HCL OneDB ODBC Driver converts binary SQL data to character C data, each byte (8 bits) of source data is represented as two ASCII characters. These characters are the ASCII character representation of the number in its hexadecimal form. For example, HCL OneDB ODBC Driver converts binary 00000001 to 01 and binary 11111111 to FF.

HCL OneDB ODBC Driver converts individual bytes to pairs of hexadecimal digits and terminates the character string with a null byte. Because of this conversion, if cbValueMax is even and is less than the length of the converted data, the last byte of the rgbValue buffer is not used. (The converted data requires an even number of bytes, the next-to-last byte is a null byte, and the last byte cannot be used.)