Grouping data items using REDEFINES in COBOL embedded SQL applications
You can use the REDEFINES
clause when declaring host variables. If you declare a member of a
group data item with the REDEFINES clause, and that group data item
is referred to as a whole in an SQL statement, any subordinate items
containing the REDEFINES clause are not expanded.
For example:
01 foo1.
10 a pic s9(4) comp-5.
10 a1 redefines a pic x(2).
10 b pic x(10).
Referring to
foo1
in an SQL statement as follows:
... INTO :foo1 ...
This statement is equivalent to:
... INTO :foo1.a, :foo1.b ...
That is, the subordinate item
a1
that is declared
with the REDEFINES clause, is not automatically expanded out in such
situations. If a1
is unambiguous, you can explicitly
refer to a subordinate with a REDEFINES clause in an SQL statement,
as follows: ... INTO :foo1.a1 ...
or
... INTO :a1 ...