The following table shows the COBOL 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.
Not every possible data description for host variables is recognized. COBOL data items must be consistent with the ones described in the following table. If you use other data items, an error can result.
SQL Column Type1 | COBOL Data Type | SQL Column Type Description |
---|---|---|
SMALLINT |
01 name PIC S9(4) COMP-5. | 16-bit signed integer |
INTEGER |
01 name PIC S9(9) COMP-5. | 32-bit signed integer |
BIGINT |
01 name PIC S9(18) COMP-5. | 64-bit signed integer |
DECIMAL(p,s) |
01 name PIC S9(m)V9(n) COMP-3. | Packed decimal |
REAL2 |
01 name USAGE IS COMP-1. | Single-precision floating point |
DOUBLE3 |
01 name USAGE IS COMP-2. | Double-precision floating point |
CHAR(n) |
01 name PIC X(n). | Fixed-length character string |
VARCHAR(n) |
01 name. |
Variable-length character string |
LONG VARCHAR6 |
01 name. |
Long variable-length character string |
CLOB(n) |
01 MY-CLOB USAGE IS SQL TYPE IS CLOB(n). |
Large object variable-length character string |
CLOB locator variable4 |
01 MY-CLOB-LOCATOR USAGE IS SQL TYPE IS CLOB-LOCATOR. | Identifies CLOB entities residing on the server |
CLOB file reference variable4 |
01 MY-CLOB-FILE USAGE IS SQL TYPE IS CLOB-FILE. | Descriptor for file containing CLOB data |
BLOB(n) |
01 MY-BLOB USAGE IS SQL TYPE IS BLOB(n). |
Large object variable-length binary string |
BLOB locator variable4 |
01 MY-BLOB-LOCATOR USAGE IS SQL TYPE IS BLOB-LOCATOR. | Identifies BLOB entities residing on the server |
BLOB file reference variable4 |
01 MY-BLOB-FILE USAGE IS SQL TYPE IS BLOB-FILE. | Descriptor for file containing BLOB data |
DATE |
01 identifier PIC X(10). | 10-byte character string |
TIME |
01 identifier PIC X(8). | 8-byte character string |
TIMESTAMP(p) |
01 identifier PIC X(p+20). 0<=p<=12 |
19 to 32 byte character string A 19 byte character string can be used, when p is 0. |
XML5 |
01 name USAGE IS SQL TYPE IS XML |
XML value |
The following data types are only available in the DBCS environment.
SQL Column Type1 | COBOL Data Type | SQL Column Type Description |
---|---|---|
GRAPHIC(n) |
01 name PIC G(n) DISPLAY-1. | Fixed-length double-byte character string |
VARGRAPHIC(n) |
01 name. |
Variable length double-byte character string with 2-byte string length indicator |
LONG VARGRAPHIC6 |
01 name. |
Variable length double-byte character string with 2-byte string length indicator |
DBCLOB(n) |
01 MY-DBCLOB USAGE IS SQL TYPE IS DBCLOB(n). |
Large object variable-length double-byte character string with 4-byte string length indicator |
DBCLOB locator variable4 |
01 MY-DBCLOB-LOCATOR USAGE IS SQL TYPE IS DBCLOB-LOCATOR. | Identifies DBCLOB entities residing on the server |
DBCLOB file reference |
01 MY-DBCLOB-FILE USAGE IS SQL TYPE IS DBCLOB-FILE. | Descriptor for file containing DBCLOB data |
Note:
|
01 identifier PIC S9(m)V9(n) COMP-3
01 identifier PIC S9(3)V COMP-3
01 identifier PIC SV9(3) COMP-3
01 identifier PIC S9V COMP-3
01 identifier PIC SV9 COMP-3