Data Type Mapping

The table below shows the mappings used by Database Connectors when interacting with DB2. Note how some mappings use a combination of the data type and XFD directive. For additional information on XFD directives, see Using XFD Directives .

If you are in a position where you need to create a COBOL file descriptor (FD) based on an existing data source table, use these mappings as a guide; although, getting them correct is not critical, as when Database Connectors opens an existing data source, mapping is carried out by matching the COBOL data names with the column names.

If you do need to accurately represent your data in the COBOL program, setting your data items as PIC X(nn) will work perfectly well (since most DB2 data types have a CHAR representation). For INTEGER types, use PIC9(9), or if you know the range of an INTEGER column (say, 0 to 999), you can match it more closely (by using PIC 9(3)).

COBOL Data Type Acu4GL for DB2
Date (DATE XFD directive applied) date
binary (BINARY XFD directive applied) char (2 * x)
varchar (VAR_LENGTH XFD directive applied)    varchar
float float
pic 9(4) smallint
pic 9(9) integer
pic 9(10) decimal(10,0)
pic 9(x)v9(y) decimal (x + y, y)
pic x(254) char
pic x(255) or greater must apply VAR_LENGTH XFD directive