Any valid COBOL host variable can be used in a SQL statement. However, this does not mean that all variables can be used. Host variables must meet certain requirements before PP2 accepts them as usable in SQL statements. See Host Variable Declaration.
Define host variables outside a structure at level 01 or 77. Host variables within a structure can be level 02 through 48. Level 49 is reserved for varying character fields. Level 66 and 88 items are ignored.
Any valid COBOL variable name can be used as a host variable name, including names with embedded hyphens.
- Begins with a number
- Is used for input in situations where the database expects a numeric constant
The USAGE IS DISPLAY clause is accepted only for a host variable of character type (PIC X(n)).
- BLANK
- WHEN ZERO
- JUSTIFIED
- SIGN
Host variables which are not SQL strings are used only to represent data values. Do not use them to represent database, table, view, macro or column names.
Declare host variables in the WORKING STORAGE SECTION or the LINKAGE SECTION of the COBOL program.
Variables declared elsewhere are not valid.