solidDB Help : solidDB reference : ODBC: Data types : Converting data from C to SQL data types
  
Converting data from C to SQL data types
This section provides information about converting data from C to SQL data types.
When an application calls SQLExecute or SQLExecDirect, the driver retrieves the data for any parameters bound with SQLBindParameter from storage locations in the application. For data-at-execution parameters, the application sends the parameter data with SQLPutData. If necessary, the driver converts the data from the data type specified by the ValueType argument in SQLBindParameter to the data type specified by the ParameterType argument in SQLBindParameter. Finally, the driver sends the data to the data source.
The following table shows the supported conversions from ODBC C data types to ODBC SQL data types.
An asterisk (*) indicates that the conversion is done without loss of precision and that the SQL data type can be reconverted to exactly the same C data type.
A hollow circle (o) indicates a supported conversion.
(s) indicates a signed data type
(u) indicates an unsigned data type
 
C data type
C
H
A
R
V
A
R
C
H
A
R
L
O
N
G
V
A
R
C
H
A
R
W
C
H
A
R
W
V
A
R
C
H
A
R
W
L
O
N
G
V
A
R
C
H
A
R
D
E
C
I
M
A
L
N
U
M
E
R
I
C
T
I
N
Y
I
N
T
(s)
T
I
N
Y
I
N
T
(u)
S
M
A
L
L
I
N
T
(s)
S
M
A
L
L
I
N
T
(u)
I
N
T
E
G
E
R
(s)
I
N
T
E
G
E
R
(u)
B
I
G
I
N
T
(s)
B
I
G
I
N
T
(u)
R
E
A
L
F
L
O
A
T
D
O
U
B
L
E
B
I
N
A
R
Y
V
A
R
B
I
N
A
R
Y
L
O
N
G
V
A
R
B
I
N
A
R
Y
D
A
T
E
T
I
M
E
T
I
M
E
S
T
A
M
P
SQL_C_CHAR
*
*
*
o
o
o
*
*
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
SQL_C_WCHAR
o
o
o
*
*
*
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
SQL_C_NUMERIC
*
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_STINYINT
o
o
o
o
o
o
o
o
*
o
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_UTINYINT
o
o
o
o
o
o
o
o
o
*
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_TINYINT
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_SSHORT
o
o
o
o
o
o
o
o
o
o
*
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_USHORT
o
o
o
o
o
o
o
o
o
o
o
*
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_SHORT
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_SLONG
o
o
o
o
o
o
o
o
o
o
o
o
*
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_ULONG
o
o
o
o
o
o
o
o
o
o
o
o
o
*
o
o
o
o
o
 
 
 
 
 
 
SQL_C_LONG
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
 
 
 
 
 
 
SQL_C_SBIGINT
o
o
o
o
o
o
o
o
o
o
o
o
o
o
*
*
o
o
o
 
 
 
 
 
 
SQL_C_UBIGINT
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
*
o
o
o
 
 
 
 
 
 
SQL_C_FLOAT
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
*
o
o
 
 
 
 
 
 
SQL_C_DOUBLE
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
*
*
 
 
 
 
 
 
SQL_C_BINARY
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
*
*
*
o
o
o
SQL_C_DATE
o
o
o
o
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
*
 
o
SQL_C_TIME
o
o
o
o
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
*
o
SQL_C_TIMESTAMP
o
o
o
o
o
o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
o
o
*
The format of the converted data is not affected by the Windows country setting.
Although the table shows a wide range of ODBC conversions, including conversions involving unsigned data types, solidDB supports only signed, not unsigned, integer data types (SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT). You can 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 can bind a numeric SQL column to a BIT data type in your C application. For example, you can 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 does not discuss BIT/SQL_BIT data types.
See
Data conversion tables from C to SQL
C to SQL data conversion examples
Go up to
ODBC: Data types