Nonstop Database, HiRDB Version 9 UAP Development Guide
This section provides the correspondence between SQL data types and COBOL data descriptions.
Data can be exchanged between variables of compatible data types and between variables of either convertible or assignable data types.
The table below shows the SQL data types and COBOL data descriptions. Note that the data descriptions in these tables can also be coded as follows:
Table F-8 SQL data types and COBOL data descriptions
| SQL data type | COBOL data description | Item coding | Remarks | |
|---|---|---|---|---|
| SMALLINT |
|
elementary-item or independent-item | -- | |
| INTEGER |
|
elementary-item or independent-item | -- | |
| DECIMAL [(p[,s])] |
|
elementary-item or independent-item | If 1 and p = s, then SV9(s). If s = 0, then [V9(s)] is omitted. |
|
| L1 elementary-item-name PICTURE S9(p-s)[V9(s)] DISPLAY SIGN
|
||||
| L1 elementary-item-name PICTURE S9(p-s)[V9(s)] DISPLAY SIGN TRAILING.#11, #12, #13 |
||||
| SMALLFLT (REAL) |
|
elementary-item or independent-item | -- | |
| FLOAT (DOUBLE PRECISION) |
|
elementary-item or independent-item | -- | |
| CHAR [(n)] [CHARACTER SET [MASTER.]EBCDIK] |
[MASTER.]EBCDIK] PICTURE X(n).#5 |
elementary-item or independent-item | 1 |
|
| CHAR[(2n)] CHARACTER SET [MASTER.]UTF16 |
If the HiRDB server's default character set is not UTF-8:#15 CHAR type cannot be used. If the HiRDB server's default character set is UTF-8:#15 L1 elementary-item-name PICTURE N(n). |
elementary-item or independent-item | 1 |
|
| VARCHAR (n) [CHARACTER SET [MASTER.]EBCDIK] |
L2 group-item-name [CHARACTER SET[IS] [MASTER.]EBCDIK].
|
A group item composed of two elementary items elementary-item-name-1: character-string-length (number of bytes) elementary-item-name-2: character-string |
1 |
|
| VARCHAR(2n) CHARACTER SET [MASTER.]UTF16 |
If the HiRDB server's default character set is not UTF-8:#15 VARCHAR type cannot be used. If the HiRDB server's default character set is UTF-8:#15 L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n). |
A group item composed of two elementary items elementary-item-name-1: character-string-length (number of bytes) elementary-item-name-2: character-string |
1 |
|
| NCHAR [(n)] | If the HiRDB server's default character set is not UTF-8:#15 L1 elementary-item-name PICTURE N(n). If the HiRDB server's default character set is UTF-8:#15 NCHAR type cannot be used. |
elementary-item or independent-item | 1 |
|
| NVARCHAR (n) | If the HiRDB server's default character set is not UTF-8:#15 L2 group-item-name
If the HiRDB server's default character set is UTF-8:#15 NVARCHAR type cannot be used. |
A group item composed of two elementary items
|
1 |
|
| MCHAR [(n)] | L1 elementary-item-name PICTURE X(n).#6 If the HiRDB server's default character set is UTF-8,#15 this can be coded as follows: L1 elementary-item-name PICTURE N(n2).#14 |
elementary-item or independent-item | 1 |
|
| MVARCHAR (n) | L2 group-item-name
If the HiRDB server's default character set is UTF-8,#15 this can be coded as follows: L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n2).#14 |
A group item composed of two elementary items
|
1 |
|
| DATE |
|
elementary-item or independent-item | -- | |
| TIME |
|
elementary-item or independent-item | -- | |
| TIMESTAMP[(p)] | L1 elementary-item-name PICTURE X(n).#6 | elementary-item or independent-item | If p = 0, n = 19. If p = 2, n = 21 or 22. If p = 4, n = 23 or 24. If p = 6, n = 25 or 26. |
|
| INTERVAL YEAR TO DAY |
|
elementary-item or independent-item | -- | |
| INTERVAL HOUR TO SECOND | L1 elementary-item-name PICTURE S9(6) COMPUTATIONAL-3. |
elementary-item or independent-item | -- | |
| ROW#3 | Combination of data items and group items in this table#1 | A group item composed of elementary items | 1 |
|
| BLOB |
|
elementary-item | Default: 1 In units of K: 1 In units of M: 1 In units of G: 1 |
|
| BINARY(n) | L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE X(n).#5, #7 |
A group item composed of two elementary items elementary-item-name-1: character-string-length elementary-item-name-2: character-string character-string-length is the byte count. |
1 |
|
| BLOB locator | L1 elementary-item-name SQL TYPE IS BLOB AS LOCATOR.#8 |
elementary-item or independent-item | -- | |
| BINARY locator | L1 elementary-item-name SQL TYPE IS BINARY AS LOCATOR.#8 |
elementary-item or independent-item | -- | |
| Indicator variable | Other than BLOB, BINARY, BLOB locator, or BINARY locator |
|
elementary-item or independent-item | -- |
| BLOB, BINARY, BLOB locator, or BINARY locator |
|
|||
| SQL statement | L2 group-item-name
|
A group item composed of two elementary items
|
1 |
|
| Column's data type | Data description that is not available because it requires data format conversion | Substitute data description that can be used |
|---|---|---|
| DECIMAL | DISPLAY (external decimal format) | COMP-3 (internal decimal format) |
| MCHAR | PICTURE N (Japanese data item) | PICTURE X (alphanumeric item) |
| DATE | PICTURE X(10) 10: Number of characters in character string representation |
PICTURE X(4) 4: Number of bytes in the format X'YYYYMMDD' |
| TIME | PICTURE X(8) 8: Number of characters in character string representation |
PICTURE X(3) 3: Number of bytes in the format X'hhmmss' |
| TIMESTAMP(p) | PICTURE X(n) n: Number of characters in character string representation |
PICTURE X(n) n=7 + p/2 n: Number of bytes in the format X'YYYYMMDDhhmmss[nn...n]' |
L2 group-item-name. 49 group-item-name_RESERVED PIC S(9) USAGE IS BINARY. 1 49 group-item-name_LENGTH PIC S(9) USAGE IS BINARY. 2 49 group-item-name_DATA PIC X(m). 3
#5:
This item can be defined using 9 in place of X. If 9 is used for definition, the operation when a character string containing a character other than a number is substituted or received as the retrieval result depends on the installed COBOL compiler.
L1 elementary-item-name PICTURE S9(9) COMPUTATIONAL.
| Data description format | Data description in COBOL | Attribute of embedded variable | |
|---|---|---|---|
| Data type | Character set name | ||
| Fixed length | L1 elementary-item-name PICTURE N(n2). |
CHAR(m) m = 2 x n2 |
UTF-16LE or UTF-16BE |
| Variable length | L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n2). |
VARCHAR(m) m = 2 x n2 |
UTF-16LE or UTF-16BE |
| Data description format | Data description in COBOL | Setting in SQL descriptor area | Setting in character set descriptor area | |
|---|---|---|---|---|
| Data code | Data length | |||
| Fixed length | L1 elementary-item-name PICTURE N(n2). |
Data code of CHAR type | 2 x n2 | UTF-16LE or UTF-16BE |
| Variable length | L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n2). |
Data code of VARCHAR type | 2 x n2 | UTF-16LE or UTF-16BE |
The following table shows the SQL data types and COBOL data descriptions when arrays are used.
Table F-9 SQL data types and COBOL data descriptions when arrays are used
| SQL data type | COBOL data description | Item coding | Remarks | |
|---|---|---|---|---|
| SMALLINT |
|
A group item composed of repetitions of data items in which the same data structure is repeated through specification of OCCURS | -- | |
| INTEGER |
|
-- | ||
| DECIMAL [(p[,s])] |
|
1 0 If p = s, SV9(s) is used. If s = 0, [V9(s)] is omitted. |
||
|
||||
|
-- | |||
| SMALLFLT (REAL) |
|
-- | ||
| FLOAT (DOUBLE PRECISION) |
|
-- | ||
| CHAR [(n)] [CHARACTER SET [MASTER.]EBCDIK] |
|
1 |
||
| CHAR[(2n)] CHARACTER SET [MASTER.]UTF16 |
If the HiRDB server's default character set is not UTF-8:#5 CHAR type cannot be used. If the HiRDB server's default character set is UTF-8:#5 L2 elementary-item-name PICTURE N(n) OCCURS m TIMES. |
1 |
||
| VARCHAR (n) [CHARACTER SET [MASTER.]EBCDIK] |
L2 group-item-name [CHARACTER SET[IS] [MASTER.]EBCDIK] OCCURS m TIMES.
|
1 |
||
| VARCHAR(2n) CHARACTER SET [MASTER.]UTF16 |
If the HiRDB server's default character set is not UTF-8:#5 VARCHAR type cannot be used. If the HiRDB server's default character set is UTF-8:#5 L2 group-item-name-2 OCCURS m TIMES. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n). |
1 |
||
| NCHAR [(n)] |
If the HiRDB server's default character set is UTF-8:#5 NCHAR type cannot be used. |
1 |
||
| NVARCHAR (n) | If the HiRDB server's default character set is not UTF-8:#5 L2 group-item-name OCCURS m TIMES.
If the HiRDB server's default character set is UTF-8:#5 NVARCHAR type cannot be used. |
1 |
||
| MCHAR [(n)] |
If the HiRDB server's default character set is UTF-8,#5 this can be coded as follows: L2 elementary-item-nameL2 elementary-item-name PICTURE N(n2) OCCURS m TIMES.#4 |
1 |
||
| MVARCHAR (n) | L2 group-item-name-2 OCCURS m TIMES.
If the HiRDB server's default character set is UTF-8,#5 this can be coded as follows: L2 group-item-name-2 OCCURS m TIMES. L3 elementary-item-name-1 PICTURE S9(4) COMPUTATIONAL. L3 elementary-item-name-2 L3 elementary-item-name-2 PICTURE N(n2).#4 |
1 |
||
| DATE |
|
-- | ||
| TIME |
|
-- | ||
| TIMESTAMP(p) | L2 elementary-item-name PICTURE X(n) OCCURS m TIMES.#2 |
If p = 0, n = 19. If p = 2, n = 21 or 22. If p = 4, n = 23 or 24. If p = 6, n = 25 or 26. |
||
| INTERVAL YEAR TO DAY |
|
-- | ||
| INTERVAL HOUR TO SECOND |
|
-- | ||
| ROW |
|
-- | ||
| BLOB | CN | CN | -- | |
| BINARY | L2 group-item-name-2 OCCURS m TIMES. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE X(n).#1 |
A group item composed of repetitions of data items in which the same data structure is repeated through specification of OCCURS. |
|
|
| BLOB locator | -- | -- | -- | |
| BINARY locator | L2 elementary-item-name SQL TYPE IS BINARY AS LOCATOR OCCURS m TIMES. |
Group item consisting of iterative data items that repeat the same data structure according to the OCCURS specification | -- | |
| Indicator variable | Other than BINARY or BINARY locator |
|
-- | |
| BINARY or BINARY locator | L2 elementary-item-name PICTURE S9(9) COMPUTATIONAL OCCURS m TIMES. |
-- | ||
| SQL statement | CN | CN | -- | |
The following table shows the SQL data types and COBOL data descriptions when repetition columns are used.
Table F-10 SQL data types and COBOL data descriptions when repetition columns are used
| SQL data type | COBOL data description | Item coding | Remarks |
|---|---|---|---|
| SMALLINT | L2 group-item-name
|
A group item composed of two elementary items | -- |
| INTEGER | L2 group-item-name
|
-- | |
| DECIMAL [(p[,s])] | L2 group-item-name
|
1 0 When p = s, SV9(s) is used. When s = 0, [V9(s)] is omitted. |
|
| L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE S9(p-s)[V9(s)] DISPLAY SIGN LEADING SEPARATE OCCURS m TIMES. |
|||
| L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE S9(p-s)[V9(s)] DISPLAY SIGN TRAILING OCCURS m TIMES. |
|||
| SMALLFLT (REAL) | L2 group-item-name
|
-- | |
| FLOAT (DOUBLE PRECISION) | L2 group-item-name
|
-- | |
| CHAR [(n)] | L2 group-item-name
|
1 |
|
| VARCHAR (n) | L2 group-item-name
|
A group item composed of two elementary items and a group item composed of one elementary item. | 1 |
| NCHAR [(n)] | If the HiRDB server's default character set is not UTF-8:#5 L2 group-item-name
If the HiRDB server's default character set is UTF-8:#5 NCHAR type cannot be used. |
A group item composed of two elementary items. | 1 |
| NVARCHAR (n) | If the HiRDB server's default character set is not UTF-8:#5 L2 group-item-name
If the HiRDB server's default character set is UTF-8:#5 NVARCHAR type cannot be used. |
A group item composed of two elementary items and a group item composed of one elementary item. | 1 |
| MCHAR [(n)] | L2 group-item-name
If the HiRDB server's default character set is UTF-8,#5 this can be coded as follows: L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE N(n2) OCCURS m TIMES.#4 |
A group item composed of two elementary items. | 1 |
| MVARCHAR (n) | L2 group-item-name
If the HiRDB server's default character set is UTF-8,#5 this can be coded as follows: L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 group-item-name-2 OCCURS m TIMES. L4 elementary-item-name-3 PICTURE S9(4) COMPUTATIONAL. L4 elementary-item-name-4 PICTURE N(n2).#4 |
A group item composed of two elementary items and a group item composed of one elementary item. | 1 |
| DATE | L2 group-item-name
|
A group item composed of two elementary items. | -- |
| TIME | L2 group-item-name
|
-- | |
| TIMESTAMP[(n)] | L2 group-item-name. L3 elementary-item-name-1 PICTURE S9(9) COMPUTATIONAL. L3 elementary-item-name-2 PICTURE X(n) OCCURS m TIMES.#2 |
If p = 0, n = 19. If p = 2, n = 21 or 22. If p = 4, n = 23 or 24. If p = 6, n = 25 or 26. |
|
| INTERVAL YEAR TO DAY | L2 group-item-name
|
-- | |
| INTERVAL HOUR TO SECOND | L2 group-item-name
|
-- | |
| ROW | CN | CN | -- |
| BLOB | CN | CN | -- |
| BINARY | CN | CN | -- |
| BLOB locator | CN | CN | -- |
| BINARY locator | CN | CN | -- |
| Indicator variable (other than BLOB, BINARY, BLOB locator, or BINARY locator) | L2 group-item-name
|
A group item composed of two elementary items. | -- |
| SQL statement | CN | CN | -- |
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.