contents.gifindex.gifprev1.gifnext1.gif

2.3 Data Types

To ensure proper and accurate data matches between the data source and your COBOL program, you must match the SQL data type with the appropriate COBOL data type. Note that only fixed-length and variable-length character strings are supported.

The following table describes data type compatibility for DB2.

SQL Type
COBOL Type
Description
CHAR(n)
01 name PIC X(n).
Fixed-length character string
DATE
01 name PIC X(10).
10-byte character string
DECIMAL(p,n)
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.
   03 name-length PIC S9(4) COMP-5.

03 name-name PIC X(n).

Variable length character string
REAL
01 name PIC S9(4) USAGE IS COMP-1.
Single-precision floating point
SMALLINT
01 name PIC S9(4) COMP-5.
16-bit signed integer
TIME
01 name PIC X(8).
8-byte character string
TIMESTAMP
01 name PIC X(26).
26-byte character string
VARCHAR(n)
01 name.
   03 name-length PIC S9(4) COMP-5.

03 name-name PIC X(n).

Variable-length character string (n <= 4000)

The following table describes data type compatibility for MSSQL.

SQL Type
COBOL Type
Description
CHAR(n)
01 name PIC X(n).
Fixed-length character string
DATETIME
01 name PIC X(25).
25-byte character string
DECIMAL(p,n)
01 name PIC S9(m) V9(n) COMP-3.
Packed decimal
(where m = p - n)
DOUBLE PRECISION
01 name USAGE IS DOUBLE.
Double-precision floating point
INTEGER
01 name PIC S9(9) COMP-5.
32-bit signed integer
REAL
01 name PIC S9(4) USAGE IS COMP-1.
Single-precision floating point
SMALLINT
01 name PIC S9(4) COMP-5.
16-bit signed integer
VARCHAR(n)
01 name.
   03 name-length PIC S9(4) COMP-5.

03 name-name PIC X(n).

Variable-length character string (n <= 4000)