Programmer Guide : Data types : Converting data from SQL to C data types
  
Converting data from SQL to C data types
This section provides information about converting data from SQL to C data types.
When an application calls SQLFetch, SQLFetchScroll, or SQLGetData, the driver retrieves the data from the data source. If necessary, it converts the data from the data type in which the driver retrieved it to the data type specified by the TargetType argument in SQLBindCol or SQLGetData. Finally, it stores the data in the location pointed to by the TargetValuePtr argument in SQLBindCol or SQLGetData (and the SQL_DESC_DATA_PTR field of the ARD).
The following table shows the supported conversions from ODBC SQL data types to ODBC C data types. A solid circle indicates the default conversion for an SQL data type (the C data type to which the data will be converted when the value of TargetType is SQL_C_DEFAULT). A hollow circle indicates a supported conversion.
For an ODBC 3.x application working with an ODBC 2.x driver, conversion from driver-specific data types might not be supported.
The format of the converted data is not affected by the Windows country setting.
solidDB® supports only signed, not unsigned, integer data types (SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT). You may bind an unsigned C variable to a signed SQL column, but you must make sure that the values you store fit within the range supported by both data types.
solidDB® does not support the BIT/SQL_BIT data type for SQL columns. However, you may bind a numeric SQL column to a BIT data type in your C application. For example, you may use a TINYINT column in your database and bind that column to a C variable of type SQL_C_BIT. The solidDB® ODBC driver will try to convert numeric types in the database to BIT data types for the C variables. The numeric data values must be 1 or 0 or NULL; other values cause a data conversion error. The table below does not discuss BIT/SQL_BIT data types.
CAUTION Although the table shows a wide range of ODBC conversions, including conversions involving unsigned data types, solidDB® supports only signed integer data types (for example, TINYINT, SMALLINT, INTEGER, and BIGINT).
C data type — SQL_C_datatype where datatype is:
Legend:
* Default conversion
o Supported conversion
SQL data type
C H A R
W C H A R
S
T
I
N
Y
I
N
T
U
T
I
N
Y
I
N
T
T
I
N
Y
I
N
T
S S H O R T
U S H O R T
S H O R T
S L O N G
U L O N G
L O N G
S
B
I
G
I
N
T
U
B
I
G
I
N
T
F L O A T
D O U B L E
N
U
M
E
R
I
C
B
I
N
A
R
Y
D A T E
T I
M E
T
I
M
E
S
T
A
M
P
SQL_CHAR
*
o
o
o
o
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 
*
 
 
 
SQL_VARBINARY
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
*
 
 
 
SQL_LONGVARBINARY
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
*
 
 
 
SQL_TYPE_DATE
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
o
*
 
o
SQL_TYPE_TIME
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
o
 
*
o
SQL_TYPE_TIMESTAMP
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
o
o
o
*
* These datatypes have the word “TYPE” in the datatype name. For example, SQL_C_TYPE_DATE, SQL_C_TYPE_TIME, and SQL_C_TYPE_TIMESTAMP.
See also
Data types