Skip to content

Appendix B. Data Types#

This appendix describes the data types of Altibase SQL data types, C data types, and the data conversion.

SQL Data Types#

To find which data types the Altibase CLI supports, call SQLGetTypeInfo().

THe user can find out what data types the ODBC driver and Altibase CLI support by calling SQLGetTypeInfo().

The following table shows the list of the Altibase SQL data types and the standard SQL type identifier.

SQL Type Identifier Data Types of Altibase Comments
SQL_CHAR CHAR(n) Character string of fixed string length n.
SQL_VARCHAR VARCHAR(n) Variable-length character string with a maximum string length n.
SQL_WCHAR NCHAR(n) Unicode character data type with fixed length(n).
N means the number of characters.
SQL_WVARCHAR NVARCHAR(n) Unicode character data type with variable length:
If declared as fixed, SQL_WVARCHAR has a fixed length.
If declared as variable, SQL_WVARCHAR has a variable length.
N means the number of characters.
SQL_DECIMAL DECIMAL(p, s) Same data type as the NUMERIC data type
SQL_NUMERIC NUMERIC(p, s) Signed, exact, numeric value with a precision p and scale s (1<=p<=38, -84<=s<=126)
SQL_SMALLINT SMALLINT 2-byte integer data type(-2^15+1 ~ 2^15-1)
SQL_INTEGER INTEGER 4-byte integer data type(-2^31+1 ~ 2^31-1)
SQL_BIGINT BIGINT 8-byte integer data type(-2^63+1 ~2^63-1)
SQL_REAL REAL The same data type as Float of C
SQL_FLOAT FLOAT(p) Fixed decimal numeric type data from -1E+120 to 1E+120 (1<=p<=38)
SQL_DOUBLE DOUBLE The same data type with DOUBLE of C
SQL_BLOB BLOB Variable-length binary data type with up to 4 Giga Bytes length
SQL_CLOB CLOB Variable-length character data type with up to 4 Giga Bytes length
SQL_TYPE_DATE DATE Year, month, and day fields, conforming to the rules of the Gregorian calendar.
SQL_TYPE_TIME DATE Hour, minute, and second fields, with valid values for hours of 00 to 23, valid values for minutes of 00 to 59, and valid values for seconds of 00 to 61.
SQL_TYPE_TIMESTAMP DATE Year, month, day, hour, minute, and second fields, with valid values as defined for the DATE and TIME data types.
SQL_INTERVAL - The result type of the DATE - DATE
SQL_BYTES BYTE(n) Binary data type with the fixed length as long as the specified size (1 byte<=n<=32000 bytes)
SQL_NIBBLE NIBBLE(n) Binary data type with the fixed length as long as the changeable size (n) (1 byte<=n<=255 bytes)
SQL_GEOMETRY GEOMETRY Internally, it implies properties of seven data types (Point, LineString, Polygon, GeometryCollection, MultiLineString, MultiPolygon, MultiPoint), and these implied properties can be distinguished as functions supported by each type:
Fixed when declared as FIXED Use a storage of length and a variable length of storage if declared as VARIABLE


C Data Types#

C data types refer to the data type of C buffer used to store the data in an application.

C data type is specified with the type argument in SQLBindCol() and SQLGetData(), and in SQLBindParameter() with cType.

The following table is the list of valid type identifiers for C data type. Also, the table lists the definitions of C data type of the ODBC Standard and the data types corresponding to each identifier.

C Type Identifier ODBC C typedef C type
SQL_C_CHAR SQLSCHAR * char *
SQL_C_WCHAR SQLWCHAR * short *
SQL_C_STINYINT SQLSCHAR signed char
SQL_C_UTINYINT SQLCHAR unsigned char
SQL_C_SBIGINT SQLBIGINT _int64
SQL_C_UBIGINT SQLUBIGINT unsigned _int64
SQL_C_SSHORT SQLSMALLINT short int
SQL_C_USHORT SQLUSMALLINT unsigned short int
SQL_C_SLONG SQLINTEGER int
SQL_C_ULONG SQLUINTEGER unsigned int
SQL_C_FLOAT SQLREAL float
SQL_C_DOUBLE SQLDOUBLE double
SQL_C_BINARY SQLCHAR * unsigned char *
C Type 식별자 ODBC C typedef C type
SQL_C_TYPE_DATE SQL_DATE_STRUCT struct tagDATE_STRUCT {
SQLSMALLINT year;
SQLSMALLINT month;
SQLSMALLINT day;
} DATE_STRUCT
SQL_C_TYPE_TIME SQL_TIME_STRUCT struct tagTIME_STRUCT {
SQLSMALLINT hour;
SQLSMALLINT minute;
SQLSMALLINT second;
} TIME_STRUCT
SQL_C_TYPE_TIMESTAMP SQL_TIMESTAMP_STRUCT struct tagTIMESTAMP_STRUCT {
SQLSMALLINT year;
SQLSMALLINT month;
SQLSMALLINT day;
SQLSMALLINT hour;
SQLSMALLINT minute;
SQLSMALLINT second;
SQLINTEGER fraction;
} TIMESTAMP_STRUCT;
SQL_C_NIBBLE SQL_NIBBLE_STRUCT struct tagNIBBLE_STRUCT {
SQLCHAR length;
SQLCHAR value[1];
} NIBBLE_STRUCT


Converting SQL Data into C Data Types#

# : Default conversion / ○ : Supported conversion

SQL_C_CHAR SQL_C_WCHAR SQL_C_BIT SQL_C_STINYINT SQL_C_UTINYINT SQL_C_SBIGINT SQL_C_UBIGINT SQL_C_SSHORT SQL_C_USHORT SQL_C_SLONG SQL_C_ULONG SQL_C_FLOAT SQL_C_DOUBLE SQL_C_BINARY SQL_C_TYPE_DATE SQL_C_TYPE_TIME SQL_C_TYPE_TIMESTAMP SQL_C_BYTES SQL_C_NIBBLE
SQL_CHAR #
SQL_VARCHAR #
SQL_WCHAR #
SQL_WVARCHAR #
SQL_DECIMAL # #
SQL_NUMERIC # #
SQL_SMALLINT #
(signed)
SQL_INTEGER #
(signed)
SQL_BIGINT #
(signed)
SQL_REAL #
SQL_FLOAT # #
SQL_DOUBLE #
SQL_BINARY #
SQL_TYPE_DATE #
SQL_TYPE_TIME #
SQL_TYPE_TIMESTAMP #
SQL_INTERVAL #
SQL_BYTES #
SQL_NIBBLE #
SQL_GEOMETRY #
  • For SQL_NUMERIC - SQL_C_BINARY, it is converted to SQL_NUMERIC_STRUCT.


Converting C Data into SQL Data types#

# : Default conversion / ○ : Supported conversion

SQL_CHAR SQL_VARCHAR SQL_WCHAR SQL_WVARCHAR SQL_DECIMAL SQL_NUMERIC SQL_SMALLINT(signed) SQL_INTEGER(signed) SQL_BIGINT(signed) SQL_REAL SQL_FLOAT SQL_DOUBLE SQL_BINARY SQL_DATE SQL_INTERVAL SQL_BYTES SQL_NIBBLE SQL_GEOMETRY
SQL_C_CHAR # # # #
SQL_C_WCHAR # #
SQL_C_BIT
SQL_C_STINYINT
SQL_C_UTINYINT
SQL_C_SBIGINT #
SQL_C_UBIGINT
SQL_C_SSHORT #
SQL_C_USHORT
SQL_C_SLONG #
SQL_C_ULONG
SQL_C_FLOAT #
SQL_C_DOUBLE # #
SQL_C_BINARY #
SQL_C_TYPE_DATE
SQL_C_TYPE_TIME
SQL_C_TYPE_TIMESTAMP
SQL_C_BYTES #
SQL_C_NIBBLE #
  • For SQL_NUMERIC - SQL_C_BINARY, it is converted to SQL_NUMERIC_STRUCT.