Table 1 describes the SQL type conversion, precision, scale, and storage length for COBOL native data types. The COBOL PICTURE clauses in the table are for signed numbers, however, unsigned numbers are handled in a similar manner.
Native Data Type | Native Length (bytes) | COBOL Usage Representation | SQL Type | Precision (p) | Scale (s) | Storage Length (bytes) |
---|---|---|---|---|---|---|
BINARY | 2 4 8 |
PIC S9 to S9(4) COMP PIC S9(5) to S9(9) COMP PIC S9(10) to S9(18) COMP |
SmallInt Integer Decimal |
1 to 4 5 to 9 10 to 18 |
n/a n/a n/a |
2 4 8 |
CHARACTER | n | PIC X(n) | Char | n | n/a | n |
DECIMAL | (p+s)/2+1 | PIC S9(p)V9(s) COMP-3 | Decimal | p+s | s | (p+s)/2+1 |
DISPLAY_ |
p+s | PIC S9(p)V9(s) | Decimal | p+s | s | (p+s)/2+1 |
FLOAT (single) |
4 |
PIC COMP-1 |
Decimal |
p+s |
s |
4 |
GRAPHIC_G | n*2 | PIC G(n) DISPLAY-1 | NChar | n | n/a | n*2 |
GRAPHIC_N | n*2 | PIC N(n) | NChar | n | n/a | n*2 |
GROUP | n (sum of all the column lengths that make up the group) | Char | n | n/a | n | |
NATIVE BINARY | 2 4 8 |
PIC S9 to S9(4) COMP-5 PIC S9(5) to S9(9) COMP-5 PIC S9(10) to S9(18) COMP-5 |
SmallInt Integer Decimal |
1 to 4 5 to 9 10 to 18 |
n/a n/a n/a |
2 4 8 |
VARCHAR | n+2 | PIC S9(4) COMP PIC X(n) | VarChar | n+2 | n/a | n+2 |
VARGRAPHIC |
(n*2)+2 | PIC S9(4) COMP PIC G(n) DISPLAY-1 | NVarChar | n+2 | n/a | (n*2)+2 |
VARGRAPHIC |
(n*2)+2 | PIC S9(4) COMP PIC N(n) | NVarChar | n+2 | n/a | (n*2)+2 |
Table 2 describes the SQL type conversion, precision, scale, and storage length for DB2® native data types. The COBOL usage representation is used only when DB2 table definitions are loaded into a flat file stage.
Native Data Type | Native Length (bytes) | COBOL Usage Representation | SQL Type | Precision (p) | Scale(s) | Storage Length (bytes) |
---|---|---|---|---|---|---|
CHARACTER | n | PIC X(n) | Char | n | n/a | n |
DATE | 10 | PIC X(10) | Date | 10 | n/a | 10 |
DECIMAL | p/2+1 | PIC S9(p)V9(s) COMP-3 | Decimal | p+s | s | (p+s)/2+1 |
GRAPHIC | n*2 | PIC G(n) DISPLAY-1 | NChar | n | n/a | n*2 |
INTEGER | 4 | PIC S9(9) COMP | Integer | 9 | n/a | 4 |
NUMERIC | p | PIC S9(p)V9(s) | Decimal | p+s | s | n |
SMALLINT | 2 | PIC S9(4) COMP | SmallInt | 2 | n/a | 2 |
TIME | 8 | PIC X(8) | Time | 8 | n/a | 8 |
TIMESTAMP | 26 | PIC x(26) | Timestamp | 26 | n/a | 26 |
VARCHAR | n+2 | PIC S9(4) COMP PIC X(n) |
VarChar | n+2 | n/a | n+2 |
VARGRAPHIC | (n*2)+2 | PIC S9(4) COMP PIC G(n) DISPLAY-1 |
NVarChar | n+2 | n/a | (n*2)+2 |
Native Data Type | Native Length (bytes) | COBOL Usage Representation | SQL Type | Precision (p) | Scale(s) | Storage Length (bytes) |
---|---|---|---|---|---|---|
BYTEINT | 1 | PIC S9(3) COMP | Integer | 3 | n/a | 2 |
CHAR | n | PIC X(n) | Char | n | n/a | n |
DATE | 10 | PIC X(10) | Date | 10 | n/a | 10 |
DECIMAL | p/2+1 | PIC S9(p)V9(s) COMP-3 | Decimal | p+s | s | (p+s)/2+1 |
FLOAT (double) | 8 | PIC COMP-2 | Decimal | p+s (default 18) | s (default 4) | 8 |
GRAPHIC | n*2 | PIC G(n) DISPLAY-1 | NChar | n | n/a | n*2 |
INTEGER | 4 | PIC S9(9) COMP | Integer | 9 | n/a | 4 |
SMALLINT | 2 | PIC S9(4) COMP | SmallInt | 2 | n/a | 2 |
TIME | 8 | PIC X(8) | Time | 8 | n/a | 8 |
TIMESTAMP | 26 | PIC X(26) | Timestamp | 26 | n/a | 26 |
VARCHAR | n+2 | PIC S9(4) COMP PIC X(n) |
VarChar | n+2 | n/a | n+2 |
VARGRAPHIC | (n*2)+2 | PIC S9(4) COMP PIC G(n) DISPLAY-1 |
NVarChar | n+2 | n/a | (n*2)+2 |