


Host variables may also be defined as COBOL tables (OCCURS clause) and as records. In this case, the table components or the record components must meet the above conventions about host variables. The record or table as a whole or its components may be specified in SQL statements. As long as all host variables and components have unique names, it is sufficient to specify the component name in the SQL statement. Otherwise, the so-called point notation applies to records:
'<record name1>.<record name2>. ...
.<record name>.<component name>' .
Here, the naming of host variables does not correspond to the COBOL rules !
Table elements are identified by subscripts. Only literals are allowed in subscripts.
There are two ways to assign indicators to structures defined as host variables: the indicators are combined to form either a record or a table. The table as a whole or its components may be used in SQL statements.
Example:

Besides records with any elements, there is a special record which allows you to use character strings of variable length. This record has the following structure:
01 NAME.
49 LENGTH PIC S9(4) BINARY SYNC.
49 CHARACTERSTRING X(4000).
Conventions on the use of character strings of variable length are:
- Both record components always have the level number 49. This level number must not be used in other cases.
- The record always consists of a 4-digit binary length specification which is followed by a character string of 10000 characters at the most.
- Any names can be chosen for the record as well as for its components.
Function:
The actual length of the character string is administered via the length field.
When a character string is inserted, the precompiler runtime system computes the actual length and stores the character string in this length in the database.
When a character string of variable length is selected, the actual length of this character string is entered into the length field.
Example:

A structure specified as parameter ':var' is expanded into its individual components. This is useful, e.g., in the INTO clause of the SELECT statement. Thereby the indicator variables needed can be specified as a structure which must contain at least as many components as the host variable.


