Supported SQL data types in C and C++ routines
Lists the supported mappings between SQL data types and C data types for routines.
Accompanying each C/C++ data type is the corresponding defined type from sqludf.h.
SQL Column Type | C/C++ Data Type | SQL Column Type Description |
---|---|---|
SMALLINT | sqlint16 SQLUDF_SMALLINT |
16-bit signed integer |
INTEGER | sqlint32 SQLUDF_INTEGER |
32-bit signed integer |
BIGINT | sqlint64 SQLUDF_BIGINT |
64-bit signed integer |
REAL FLOAT(n) where 1<=n<=24 |
float SQLUDF_REAL |
Single-precision floating point |
DOUBLE FLOAT FLOAT(n) where 25<=n<=53 |
double SQLUDF_DOUBLE |
Double-precision floating point |
DECIMAL(p, s) | Not supported. | To pass a decimal value, define the parameter to be of a data type castable from DECIMAL (for example CHAR or DOUBLE) and explicitly cast the argument to this type. |
CHAR(n) | char[n+1] where n is large enough to
hold the data
1<=n<=255
SQLUDF_CHAR |
Fixed-length, null-terminated character string |
CHAR(n) FOR BIT DATA | char[n] where n is large enough to hold
the data
1<=n<=255
SQLUDF_CHAR |
Fixed-length, not null-terminated character string |
VARCHAR(n) | char[n+1] where n is
large enough to hold the data 1<=n<=32 672
SQLUDF_VARCHAR |
Null-terminated varying length string |
VARCHAR(n) FOR BIT DATA | struct {
sqluint16 length; char[n] } 1<=n<=32 672 SQLUDF_VARCHAR_FBD |
Not null-terminated varying length character string |
LONG VARCHAR | struct {
sqluint16 length; char[n] } 1<=n<=32 700 SQLUDF_LONG |
Not null-terminated varying length character string |
CLOB(n) | struct {
sqluint32 length; char data[n]; } 1<=n<=2 147 483 647 SQLUDF_CLOB |
Not null-terminated varying length character string with 4-byte string length indicator |
BINARY | char[n] where n is large enough to
hold the data
1<=n<=255
SQLUDF_BINARY |
Fixed-length, not null-terminated binary string |
VARBINARY |
struct {
sqluint16 length; char[n] } 1<=n<=32 672 SQLUDF_VARBINARY |
Not null-terminated varying length binary string |
BLOB(n) | struct {
sqluint32 length; char data[n]; } 1<=n<=2 147 483 647 SQLUDF_BLOB |
Not null-terminated varying binary string with 4-byte string length indicator |
DATE | char[11]
SQLUDF_DATE |
Null-terminated character string of the following
format:
|
TIME | char[9]
SQLUDF_TIME |
Null-terminated character string of the following
format:
|
TIMESTAMP | char[20] - char[33]
SQLUDF_STAMP |
Null-terminated character string of the following
format:
The character string can be from 19 - 32 bytes in length depending on the number of fractional seconds specified. The fractional seconds of the TIMESTAMP data type can be optionally specified with 0-12 digits of timestamp precision. For example:
When a timestamp value is assigned to a timestamp variable with a different number of fractional seconds, the value is either truncated or padded with 0's to match the format of the timestamp variable. |
LOB LOCATOR | sqluint32
SQLUDF_LOCATOR |
32-bit signed integer |
GRAPHIC(n) | sqldbchar[n+1] where n is
large enough to hold the data 1<=n<=127
SQLUDF_GRAPH |
Fixed-length, null-terminated double-byte character string |
VARGRAPHIC(n) | sqldbchar[n+1] where n is
large enough to hold the data 1<=n<=16 336
SQLUDF_GRAPH |
Null-terminated, variable-length double-byte character string |
LONG VARGRAPHIC | struct {
sqluint16 length; sqldbchar[n] } 1<=n<=16 350 SQLUDF_LONGVARG |
Not null-terminated, variable-length double-byte character string |
DBCLOB(n) | struct {
sqluint32 length; sqldbchar data[n]; } 1<=n<=1 073 741 823 SQLUDF_DBCLOB |
Not null-terminated varying length character string with 4-byte string length indicator |
XML AS CLOB | struct {
sqluint32 length; char data[n]; } 1<=n<=2 147 483 647 SQLUDF_CLOB |
Not null-terminated varying length serialized character string with 4-byte string length indicator. |
Note: XML data types can only be implemented as CLOB data
types in external routines implemented in C or C++.
Note: The following data types are only available in the
DBCS or EUC environment when precompiled with the WCHARTYPE NOCONVERT
option:
- GRAPHIC(n)
- VARGRAPHIC(n)
- LONG VARGRAPHIC
- DBCLOB(n)