I have a requirement to change Key field values (Mask to another value) of the Root segment based on some criteria (Not all Root keys need to be modified). The DB is very large and it has multiple Child segments. Each Root occurence can have upto 5000 Child Segment Occurences.
The following is the structure of the DB:
Root Segment -- Level 0
----Child Segment A -- Level 1
--------Child Segment D -- Level 2
--------Child Segment E -- Level 2
-----Child Segment B -- Level 1
-----Child Segment C -- Level 1
---------Child Segment F -- Level 2
---------Child Segment G -- Level 2
--------------Child Segment H -- Level 3
I was initially thinking of using IMS unload and change the Key values in the Unloaded file and then Load it back. But it seems, the keys should be in sorted order. Hence this Approach seems to require a Group Sort of the data to be done. Also I am not sure if the key values are stored in the First 31 bytes of the Unloaded Data. The Actual Segment data starts from 32 Byte.
The only feasible option I could think of is to write a BMP program to Insert all the segments with new Values and delete the segments with old values. But it requires lot of IO for the Insert/Deletes.
Could you please suggest me a best approach that I could follow.
Delete the old root segments and Insert the new root segments would be the possible approach.
Instead of holding the DB for all the roots while reading, the logic can be split into two programs.
1) One is to find & write the old root and its child segments along with the modified root details into a file with a indicator for Insert and Delete.
2) Second is to read the above file and do the DB call as per Insert or Delete indicator