Previous Topic: Host StructuresNext Topic: Indicator Variables


Extended Format for Host Variables in COBOL

The extended format for the host variable supports the COBOL construct of qualified names. However, use of the extended format differs from the COBOL construct. For example, if you define:

  01 DATE1.
       03 MONTH1  PIC 99
       03 DAY1    PIC 99
       03 YEAR1   PIC 99

you reference DAY1 in the COBOL construct as follows:

  MOVE DAY1 OF DATE1 TO TEMP-DAY

In an SQL statement, you reference DAY1 as follows:

   SELECT NEWDAY
   INTO :DATE1.DAY1

Host Variable Data Types

See Character Strings for more information on host variable data types.

For more information about SQL data types, see Data Types.

Using Colons in Host Variables

Host variables must be preceded by a colon (:) if the host identifier is identical to an SQL reserved word. Colons are always required on indicator variables. When used, the colon can be preceded by a blank, an open parenthesis or a comma, as shown in the following examples where b represents a blank.

 b:host-variable
 (:host-variable
 ,:host-variable

Colons may be omitted only in the following contexts:

Note: All except the last of the previous are those in which only host variables are allowed, not both column references and host variables. When both column references and host variable references are allowed, the colon should be used on host variables to avoid confusion, because CA Datacom/DB may not be able to give a clear indication of error when the colon is omitted. In a context in which either a host variable or column can be referenced, the use of an unqualified name without a colon is interpreted by the Preprocessor as a reference to a column, even if there is a host variable with that same name. If the host variable was what was intended, the results are confusing but no error is issued.

If a qualified name without a colon such as GROUPX.V is used, and GROUPX is a host structure that contains V, GROUPX.V is always interpreted by CA Datacom/DB as a reference to a host variable. If the group name happened to be the same as a table name and the host variable within the group was the same as a column name, that column could never be referenced because CA Datacom/DB would always interpret the name as the host structure reference. You should therefore avoid naming host structures the same as any possible qualifiers of a column-name that you could possibly specify in your program.