The following table describes data type compatibility for DB2.
SQL Type | COBOL Type | Description |
---|---|---|
CHAR | 01 name PIC X(n) | Fixed-length character string |
DATE | 01 name PIC X(10) | 10-byte character string |
DECIMAL | 01 name PIC S9(M) V9(N) COMP-3. | Packed decimal
(where m = p - n) |
DOUBLE | 01 name USAGE IS DOUBLE. | Double-precision floating point |
INTEGER | 01 name PIC S9(9) COMP-5. | 32-bit signed integer |
LONG VARCHAR(n) | 01
name.
49 name-length PIC S9(4) COMP-5. 49 name-name PIC X(n). |
Variable-length character string |
REAL | 01 name PIC S9(4) USAGE IS COMP-1. | Single-precision floating point |
TIME | 01 name PIC X(8). | 8-byte character string |
TIMESTAMP | 01 name PIC X(26). | 26-byte character string |
VARCHAR(n)* | 01
name.
49 name-length PIC S9(4) COMP-5. 49 name-name PIC X(n). |
Variable-length character string (n <= 4000) |
* To be treated as a VARCHAR, the elementary items in a group item consisting of only a numeric item and a character item need to be level 49 as in the following:
01 my-record. 49 my-number pic s9(3) comp-5. 49 my-name pic x(20).