Names of REXX Stemmed Variables Created by DECLARE REXXSTEM

Names of REXX stemmed variables created by DECLARE REXXSTEM.
In the explicit form of the DECLARE REXXSTEM statement, REXX stem names are supplied (by the programmer) through the INTO clause. In the implicit form, the DECLARE REXXSTEM service derives the REXX stem names.
In both cases,
RLX
appends numeric subscripts after the stem name to create arrays of variables that share the same stem (for example, stem.1, stem.2, stem.3). These stemmed arrays serve as the host data and indicator variables into which the column values of the discrete result rows are copied.
When
RLX
implicitly derives stemmed variable names, the name of the SQL result column becomes the name of the host data variable unless the SQL result column has no name. This can occur in the following circumstances:
  • SQL Built-in functions:
    AVG(COLUMN1)
  • Multi-term expressions:
    COLUMN_NAME + 10
  • Literal constants:
    10 or 'CONSTANT'
In these instances,
RLX
derives the name of a host data variable as follows:
Each (D)ata (V)ariable becomes DVxxx where xxx is the ordinal number (1st, 2nd, 3rd, ...) of the SELECT list column for which
RLX
is deriving a default name. For example, if
AVG(COLUMN3)
is the third column in the SELECT list,
RLX
uses DV3 as the name of the host data variable (and REXX stem).
Should the SQL result column permit NULL values,
RLX
also creates an array of host indicator variables whose names follow a similar convention. Each indicator variable is named IVxxx where xxx corresponds to the ordinal number (1st, 2nd, 3rd, ...) of the SELECT list column that is associated with the indicator variable. Suppose, for example, the first column in the SELECT list permits NULLS.
RLX
will then create an indicator variable (and REXX stem) named IV1. As a further illustration of derived names, consider the following DECLARE REXXSTEM example:
"RLX declare fruit_table rexxstem for Select avg(apples), oranges + 10, 'peaches', pears from fruit_table
In this example, assume that each result column in the SELECT list -- except the literal constant 'peaches' -- can assume a value of NULL. In this case,
RLX
derives the names of data and indicator variables as if the following INTO clause were specified:
Into :DV1:IV1, :DV2:IV2, :DV3, :pears:IV4 (1) (2) (3) (4) (5) (6) (7)
Where
(1) The built-in function
avg(apples)
is the first column in the SELECT list. It becomes host data variable DV1.
(2) The function
avg(apples)
may assume a value of NULL. As such,
RLX
creates a host indicator variable named IV1 for this first SELECT list column.
(3) The multi-term expression
oranges + 10
is the second column in the SELECT list. It becomes host data variable DV2.
(4)
Oranges + 10
may assume a value of NULL. As such,
RLX
creates an indicator variable named IV2 for this second SELECT list column.
(5) The constant
peaches
is the third column in the SELECT list. Thus, it becomes host data variable DV3.
(6)
RLX
uses the name of the query result column when it is non-blank. As such, the host data variable created by
RLX
is named
Pears
.
(7) The column
Pears
may assume a value of NULL. As such,
RLX
creates an indicator variable named IND4 for this fourth SELECT list column.