Supported SQL data types in C and C++ embedded SQL applications
The following tables show the C and C++ equivalent of each column type. When the precompiler finds a host variable declaration, it determines the appropriate SQL type value. The database manager uses this value to convert the data exchanged between the application and itself.
SQL Column Type1 | C and C++ Data Type | SQL Column Type Description |
---|---|---|
SMALLINT
(500 or 501) |
short
short int sqlint16 |
16-bit signed integer |
INTEGER
(496 or 497) |
32-bit signed integer | |
BIGINT
(492 or 493) |
64-bit signed integer | |
REAL5
(480 or 481) |
float | Single-precision floating point |
DOUBLE6
(480 or 481) |
double | Double-precision floating point |
DECIMAL(p,s)
(484 or 485) |
No exact equivalent; use double | Packed decimal (Consider using the CHAR and DECIMAL functions to manipulate packed decimal fields as character data.) |
CHAR(1)
(452 or 453) |
char | Single character |
CHAR(n)
(452 or 453) |
No exact equivalent; use char[n+1] where n is large enough to hold the
data 1<=n<=255
|
Fixed-length character string |
VARCHAR(n)
(448 or 449) |
struct tag {
short int; char[n] } 1<=n<=32 672 |
Non null-terminated varying character string
with 2-byte string length indicator. Note: A
host variable structure of the following form is always treated as
a VARCHAR host variable and cannot be declared:
|
Alternatively, use char[n+1] where n
is large enough to hold the data 1<=n<=32 672
|
Null-terminated variable-length character string
Note: Assigned an SQL type of 460/461.
|
|
LONG VARCHAR8
(456 or 457) |
struct tag {
short int; char[n] } 32 673<=n<=32 700 |
Non null-terminated varying character string with 2-byte string length indicator |
CLOB(n)
(408 or 409) |
sql type is
clob(n) 1<=n<=2 147 483 647 |
Non null-terminated varying character string with 4-byte string length indicator |
CLOB locator variable7
(964 or 965) |
sql type is
clob_locator |
Identifies CLOB entities residing on the server |
CLOB file reference variable7
(920 or 921) |
sql type is
clob_file |
Descriptor for file containing CLOB data |
BLOB(n)
(404 or 405) |
sql type is
blob(n) 1<=n<=2 147 483 647 |
Non null-terminated varying binary string with 4-byte string length indicator |
BLOB locator variable7
(960 or 961) |
sql type is
blob_locator |
Identifies BLOB entities on the server |
BLOB file reference variable7
(916 or 917) |
sql type is
blob_file |
Descriptor for the file containing BLOB data |
DATE
(384 or 385) |
Null-terminated character form | Allow at least 11 characters to accommodate the null-terminator |
VARCHAR structured form | Allow at least 10 characters | |
TIME
(388 or 389) |
Null-terminated character form | Allow at least 9 characters to accommodate the null-terminator |
VARCHAR structured form | Allow at least 8 characters | |
TIMESTAMP(p)
4(392 or 393) |
Null-terminated character form | Allow 20- 33 characters to accommodate for the null-terminator |
VARCHAR structured form | Allow 19-32 characters.
|
|
XML8
(988 or 989) |
struct {
sqluint32 length; char data[n]; } 1<=n<=2 147 483 647 SQLUDF_CLOB |
XML value |
BINARY
|
unsigned char myBinField[n];
1<= n <=255 |
Binary data |
VARBINARY
|
struct
myVarBinField_t {sqluint16 length;char data[n];} myVarBinField; 1<= n <=32 672 |
Varbinary data |
The following data types are only available in the DBCS or EUC environment when precompiled with the WCHARTYPE NOCONVERT option.
SQL Column Type1 | C and C++ Data Type | SQL Column Type Description |
---|---|---|
GRAPHIC(1)
(468 or 469) |
sqldbchar | Single double-byte character |
GRAPHIC(n)
(468 or 469) |
No exact equivalent; use sqldbchar[n+1] where n is large
enough to hold the data 1<=n<=127
|
Fixed-length double-byte character string |
VARGRAPHIC(n)
(464 or 465) |
struct tag {
short int; sqldbchar[n] } 1<=n<=16 336 |
Non null-terminated varying double-byte character string with 2-byte string length indicator |
Alternatively use sqldbchar[n+1] where
n is large enough to hold the data 1<=n<=16 336
|
Null-terminated variable-length double-byte
character string Note: Assigned an SQL type of 400/401.
|
|
LONG VARGRAPHIC8
(472 or 473) |
struct tag {
short int; sqldbchar[n] } 16 337<=n<=16 350 |
Non null-terminated varying double-byte character string with 2-byte string length indicator |
The following data types are only available in the DBCS or EUC environment when precompiled with the WCHARTYPE CONVERT option.
SQL Column Type1 | C and C++ Data Type | SQL Column Type Description |
---|---|---|
GRAPHIC(1)
(468 or 469) |
wchar_t |
|
GRAPHIC(n)
(468 or 469) |
No exact equivalent; use wchar_t [n+1] where n is large
enough to hold the data 1<=n<=127
|
Fixed-length double-byte character string |
VARGRAPHIC(n)
(464 or 465) |
struct tag {
short int; wchar_t [n] } 1<=n<=16 336 |
Non null-terminated varying double-byte character string with 2-byte string length indicator |
Alternately use char[n+1] where n is
large enough to hold the data 1<=n<=16 336
|
Null-terminated variable-length double-byte
character string Note: Assigned an SQL type of 400/401.
|
|
LONG VARGRAPHIC8
(472 or 473) |
struct tag {
short int; wchar_t [n] } 16 337<=n<=16 350 |
Non null-terminated varying double-byte character string with 2-byte string length indicator |
The following data types are only available in the DBCS or EUC environment.
SQL Column Type1 | C and C++ Data Type | SQL Column Type Description |
---|---|---|
DBCLOB(n)
(412 or 413) |
sql type is
dbclob(n) 1<=n<=1 073 741 823 |
Non null-terminated varying double-byte character string with 4-byte string length indicator |
DBCLOB locator variable7
(968 or 969) |
sql type is
dbclob_locator |
Identifies DBCLOB entities residing on the server |
sql type is
dbclob_file |
Descriptor for file containing DBCLOB data | |
Note:
|
- The data type
char
can be declared aschar
orunsigned char
. - The database manager processes
null-terminated variable-length character string data type char[n]
(data type 460), as VARCHAR(m).
- If LANGLEVEL is SAA1, the host variable length m equals
the character string length n in char[n] or the number
of bytes preceding the first null-terminator (
\0
), whichever is smaller. - If LANGLEVEL is MIA, the host variable length m equals
the number of bytes preceding the first null-terminator (
\0
).
- If LANGLEVEL is SAA1, the host variable length m equals
the character string length n in char[n] or the number
of bytes preceding the first null-terminator (
- The database manager processes
null-terminated, variable-length graphic string data type,
wchar_t[n]
orsqldbchar[n]
(data type 400®), as VARGRAPHIC(m).- If LANGLEVEL is SAA1, the host variable length m equals
the character string length n in
wchar_t[n]
orsqldbchar[n]
, or the number of characters preceding the first graphic null-terminator, whichever is smaller. - If LANGLEVEL is MIA, the host variable length m equals the number of characters preceding the first graphic null-terminator.
- If LANGLEVEL is SAA1, the host variable length m equals
the character string length n in
- Unsigned numeric data types are not supported.
- The C and C++ data type
int
is not allowed because its internal representation is machine dependent.