HP 3000 Manuals

Host Variable Groups and Indicator Arrays [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Language Reference for the Series 700 and 800

Host Variable Groups and Indicator Arrays 

When host variables are declared in a group item, an SQL statement which
needs to refer to each of these variables in turn can be abbreviated by
referring instead to the group name.  If you need to associate indicator
variables with these host variables, define a table of indicator
variables with as many instances as there are host variables, and
reference this table (the item with the OCCURS clause, not a group item
containing it).

The SQLDB2 directive must be set to enable the use of group host
variables and group indicator arrays.

Example 

Suppose variables are defined as follows:

         exec sql begin declare section end-exec

     01  host-structure.
         03  sumh pic s9(9) comp-5.
         03  avgh pic s9(9) comp-5.
         03  minh pic s9(9) comp-5.
         03  maxh pic s9(9) comp-5.
         03  varchar.

              49  varchar-l pic s9(4) comp.
              49  varchar-d pic x(1000).
     01  indicator-table.
         03  indic pic s9(4) comp-5 occurs 4.
     01  redefines indicator-table.
         03  indic1 pic s9(4) comp-5.
         03  indic2 pic s9(4) comp-5.
         03  indic3 pic s9(4) comp-5.
         03  indic4 pic s9(4) comp-5.

         exec sql end declare section end-exec

Then the procedural statement:

     exec sql fetch s3 into
         :host-structure:indic
     end-exec

is equivalent to:

     exec sql fetch s3 into
         :sumh:indic1, :avgh:indic2, :minh:indic3,
         :maxh:indic4, varchar
     end-exec

Note that the four declared indicator variables are allocated to the
first four host variables.  If five or more had been declared then all
five host variables would have an associated indicator variable.

Note also that the table of indicator variables is redefined only to show
the equivalent SQL statement (subscripting is not allowed in SQL
statements).  The redefinition can be omitted and the COBOL program refer
to the indicator variables using subscripting, if desired.



MPE/iX 5.0 Documentation