Changing the key of a sorted chained set
search cancel

Changing the key of a sorted chained set


Article ID: 141443


Updated On:


IDMS IDMS - Database


An IDMS network database may have a chained set defined as sorted, with an existing sortkey. A need may arise to change that sortkey, indicating a new sort sequence for the set. What utility can be used to accomplish this? Unload/Reload? Reorg? Restructure? How can this change be done? 


Release: All supported releases.


The unload/reload utility statements will not handle this, and neither will any other utility.

There are two cases to consider.

  1. It might be possible that the structure of the existing database after the schema has been changed is still consistent with that new schema. For example, if the set is defined as DUPLICATES NOT ALLOWED and a new field is being added at the end of the symbolic key, then by definition, the database already matches the new schema and no further action is necessary. If this is not the case, option 2 must be used.
  2. It wiill be necessary to create two user-written programs. 

The first program would read the records as is, using the old sortkey definition, area sweeping on the owner record. For each owner record, walk the set, writing the owner and member dbkeys to a flat file, then disconnecting the member record from the set. If the set is defined as Mandatory Automatic, create a temporary schema/subschema that defines the set as Optional Manual for the DISCONNECT to work. Then the program should re-get the owner record to re-establish currency for the area sweep. (This part is not necessary if the owner and member records are in different areas.)
After the first program is complete, make the necessary changes to the schema/subschema, changing the set definition to specify the new sortkey fields. In the new schema/subschema pair, the set should be defined (for now) as OPTIONAL MANUAL. 

The second program must read the flat file created above, get currency on the owner and member records, then issue a CONNECT to join the member to the owner. The member will be connected in the correct (new) set order.
When that program is done executing, modify the new schema/subschema set definition back to Mandatory Automatic if needed.

The sample programs provided in the following Knowledge Documents were created for a slightly different purpose, but can be used as a basis for this exercise.

How to convert a sorted set to a user-owned index
Utility program to help rebuild user-owned indexed set


Additional Information

Be careful using sorted chained sets - see Sorted chained sets should be used with caution.