Technical data

Figure 6–3 shows a set occurrence for SORT_SET where MEMBER-B’s key (KEY
3) was changed to KEY 8. Before altering the record’s key, the set currency
pointed to MEMBER-B, and a FETCH NEXT MEMBER WITHIN SORT_SET
fetched MEMBER-C. However, the modification to MEMBER-B’s key repositions
the record within the set occurrence. Now, a FETCH NEXT MEMBER WITHIN
SORT_SET fetches the MEMBER-D record.
Figure 6–3 Modifying Members of Sorted Sets
(CURRENT OF SET)
BEFORE MODIFYING MEMBER B
SORT−OWNER
MEMBER−A KEY 1
MEMBER−B KEY 3
MEMBER−D KEY 9
MEMBER−C KEY 6
(CURRENT OF SET)
SORT−OWNER
MEMBER−A KEY 1
MEMBER−C KEY 6
MEMBER−D KEY 9
MEMBER−B KEY 8
AFTER MODIFYING
MEMBER B
ZK−1510−GE
When you change the contents of a data item specified in the ORDER IS SORTED
clause and you do not want the set’s currency to change, use the RETAINING
clause with the MODIFY statement. Thus, MODIFY repositions the record and
RETAINING keeps the currency indicator pointing at the position vacated by
the record. Figure 6–4 shows how the following example retains currency for
SORT_SET.
FETCH NEXT WITHIN SORT_SET.
IF MEMBER_KEY = "KEY 3"
MOVE "KEY 8" TO MEMBER_KEY
MODIFY MEMBER_KEY RETAINING SORT_SET.
DML Programming—Tips and Techniques 6–7