19.6.2 Correspondences between SQL data types and data descriptions
The following table shows the correspondences between the SQL data types and the data descriptions in C or C++.
|
No. |
SQL data type |
Data description in C or C++ |
Area length (bytes) |
|---|---|---|---|
|
1 |
CHAR(n) |
char variable-name [n + 1]; |
n + 1 |
|
2 |
VARCHAR(n) |
a_rdb_M_VARCHAR(n) variable-name; |
n + 4 |
|
3 |
STRING |
a_rdb_M_VARCHAR(32000000) variable-name; |
32,000,004 |
|
4 |
BIGINT |
long long variable-name; |
8 |
|
5 |
INTEGER#4 |
int variable-name; |
4 |
|
6 |
SMALLINT#5 |
short variable-name; |
2 |
|
7 |
DECIMAL(m,n) |
unsigned char variable-name[p#1]; |
p#1 |
|
8 |
NUMERIC(m,n) |
||
|
9 |
REAL |
float variable-name; |
4 |
|
10 |
DOUBLE PRECISION |
double variable-name; |
8 |
|
11 |
FLOAT |
||
|
12 |
DATE |
unsigned char variable-name[4]; |
4 |
|
13 |
TIME(p)#2 |
unsigned char variable-name[3 + (p + 1) ÷ 2]; |
3 + (p + 1) ÷ 2 |
|
14 |
TIMESTAMP(p)#2 |
unsigned char variable-name[7 + (p + 1) ÷ 2]; |
7 + (p + 1) ÷ 2 |
|
15 |
BINARY(n) |
unsigned char variable-name[n]; |
n |
|
16 |
VARBINARY(n) |
a_rdb_M_VARBINARY(n) variable-name; |
n + 2 |
|
17 |
BOOLEAN |
char variable-name; |
1 |
|
18 |
UUID |
unsigned char variable-name[16]; |
16 |
|
19 |
ROW |
unsigned char variable-name[row-length#3]; |
row-length#3 |
- Legend:
-
m, n: Positive integer
- #1
-
The value of p depends on the value of m (precision).
No.
Value of m
Value of p
1
1 ≤ m ≤ 4
2
2
5 ≤ m ≤ 8
4
3
9 ≤ m ≤ 16
8
4
17 ≤ m ≤ 38
16
- #2
-
p indicates the fractional seconds precision and its value is 0, 3, 6, 9, or 12.
- #3
-
The row length is the sum of the data lengths of all the columns. For details about determining the data length of a column, see Length of data storage in the topic List of data types in the manual HADB SQL Reference.
- #4
-
If the integer data type format is in legacy format, the data description in C or C++ language will be "long long variable-name;" and the area length will be 8.
- #5
-
If the integer data type format is in legacy format, the data description in C or C++ language will be "int variable-name;" and the area length will be 4.
Macros used in the data descriptions are expanded as shown below.
- ■ a_rdb_M_VARCHAR(n) variable-name;
-
struct { unsigned int Length ; /* Data length */ char Data[n] ; /* Character string data */ } - ■ a_rdb_M_VARBINARY(n) variable-name;
-
struct { unsigned short Length ; /* Data length */ unsigned char Data[n] ; /* Binary data */ }