Programmer Guide : Data types : SQL to C data conversion examples
  
SQL to C data conversion examples
The following examples illustrate how the driver converts SQL data to C data.
SQL type identifier
SQL data values
C type identifier
Buffer length
*TargetValuePtr
SQLSTATES
SQL_CHAR
abcdef
SQL_C_CHAR
7
abcdef\0 [1]
N/A
SQL_CHAR
abcdef
SQL_C_CHAR
6
abcde\0 [1]
01004
SQL_DECIMAL
1234.56
SQL_C_CHAR
8
1234.56\0 [1]
N/A
SQL_DECIMAL
1234.56
SQL_C_CHAR
5
1234\0 [1]
01004
SQL_DECIMAL
1234.56
SQL_C_CHAR
4
----
22003
SQL_DECIMAL
1234.56
SQL_C_FLOAT
ignored
1234.56
N/A
SQL_DECIMAL
1234.56
SQL_C_SSHORT
ignored
1234
01S07
SQL_DECIMAL
1234.56
SQL_C_STINYINT
ignored
----
22003
SQL_DOUBLE
1.2345678
SQL_C_DOUBLE
ignored
1.2345678
N/A
SQL_DOUBLE
1.2345678
SQL_C_FLOAT
ignored
1.234567
N/A
SQL_DOUBLE
1.2345678
SQL_C_STINYINT
ignored
1
N/A
SQL_TYPE_DATE
1992-12-31
SQL_C_CHAR
11
1992-12-31\0 [1]
N/A
SQL_TYPE_DATE
1992-12-31
SQL_C_CHAR
10
 
22003
SQL_TYPE_DATE
1992-12-31
SQL_C_ TIMESTAMP
ignored
1992,12,31, 0,0,0,0 [2]
N/A
SQL_TYPE_TIMESTAMP
1992-12-31 23:45:55.12
SQL_C_CHAR
23
1992-12-31 23:45:55.12\0 [1]
N/A
SQL_TYPE_TIMESTAMP
1992-12-31 23:45:55.12
SQL_C_CHAR
22
1992-12-31 23:45:55.1\0 [1]
01004
SQL_TYPE_TIMESTAMP
1992-12-31 23:45:55.12
SQL_C_CHAR
18
----
22003
[1] "\0" represents a null-termination byte. The driver always null-terminates SQL_C_CHAR data.
[2] The numbers in this list are the numbers stored in the fields of the TIMESTAMP_STRUCT structure.
See also
Data types