The following table shows the COBOL declarations that are allowed for defining host variables. All other types of COBOL declarations will be rejected. Allowed abbreviations are shown in the section Allowed Data Declaration Abbreviations.
Data Type | COBOL Data Declaration | Comments |
---|---|---|
char | 01
identifier PIC X(n).
01 identifier PICTURE IS X(n). |
n is a positive integer representing the length of the CHAR column value assigned to the host variable. |
varchar | 01 identifier
49 identifier PIC S9(ni) COMP. 49 identifier PIC X(nc). |
ni is a positive integer from 1 to 4, representing the length of the numeric column value assigned to the variable containing the string length.
nc is a positive integer equal to the length of the largest VARCHAR column value that can be assigned to the host variable. |
smallint | 01
identifier PIC S9(4) COMP.
01 identifier PIC S9(n) COMP. 01 identifier PIC S9(n) USAGE IS COMP. |
n is a positive integer from 1 to 4, representing the variable length. No decimal points are allowed. Anything other than 9s in the Picture clause makes data item unacceptable as a host variable. PIC S and COMP are required. You may use COMP-4 or COMP-5 in place of COMP if necessary. |
integer | 01
identifier PIC S9(9) COMP.
01 identifier PIC S9(n) COMP. 01 identifier PIC S9(n) USAGE IS COMP. |
n is a positive integer from 5 to 9. No decimal point is allowed. Anything other than 9s in the Picture clause will make the data item unacceptable as a host variable. PIC S and COMP are required. You may use COMP-4 or COMP-5 in place of COMP if necessary. |
decimal | 01
identifier PIC S9V COMP-3.
01 identifier PIC S9(n) V COMP-3. 01 identifier PIC S9(n) V9(m) COMP-3. 01 identifier PIC S9(n) V9(m) USAGE IS COMP-3. |
n and m are positive integers; n + m cannot exceed 15. You must include a V to denote the decimal point. Anything other than 9s and a V in the Picture clause will make the data item unacceptable as a host variable. PIC S and COMP-3. are required. |
float | 01
identifier COMP-2.
01 identifier USAGE IS COMP-3. |
COMP-2. or COMP-3. is required. |
date | 01
identifier PIC X(n).
01 identifier PICTURE IS X(n). |
n must be an integer representing the length of the date string. For example, if the date string is in the format MM/DD/YY, n may equal 8. If in the format MM/DD/YYYY, n should equal 10. Make sure your date format is set correctly in the Options utility. See the Option utility's online help for information about modifying the date/time representation. |
time | 01
identifier PIC X(n).
01 identifier PICTURE IS X(n). |
n must be an integer representing the length of the time string. To include seconds, n must be at least 8. For example, a time string in the format HH:MM requires that n equal at least 5, while a time string in the format HH:MM:SS requires that n equal at least 8. |
result set locator | 01 identifier SQL TYPE IS RESULT-SET- LOCATOR. | A 4-byte value used by DB2 to uniquely identify a query result set returned by a stored procedure. |