Summary -

In this topic, we described about the below sections -

Secondary index can be used to process the database with different key which is other than primary. Databases often require multiple ways of processing. Secondary index can be used to provide multiple access routes to one database. Retrieval of database records in an alternate sequence.

Retrieval of a segment based on a condition in its dependent segments. Ordering of a non-ordered database. The segment to be retrieved using the secondary index is called the target segment. The segment used to build the secondary index is called the Source segment. The target is retrieved based upon data in the source segment.

The secondary index acts actually as a database. The segments in the index database are called pointer segments. Any segment in a database hierarchy can be specified as the target of a secondary index. A secondary index must be a VSAM dataset. The source and target segment can be the same segment.

Steps to define secondary index:

  1. Define the secondary index DBD.
  2. Use the LCHILD statement to establish the relationship between the secondary index and the target segment.
  3. Use XDFLD statement to define the fields to build the secondary index.

In the PSB, secondary index must be defined for the secondary index created. The PROCSEQ must be set to the secondary index DBD name. The secondary index database can process itself.

IMS can replicate information from the source segment into the pointer segment and known as duplicate data. The application program can view the entire data portion of the pointer segment.

The application program view includes the search, subsequence and duplicates data fields. The index database should never be updated directly. All updates should be done to the prime database and IMS will maintain the index. To process the secondary index database, the PSB should refer the secondary index database.

Secondary Data structure:

When a secondary index has a target segment which is not the root, the processing sequence will be changed like below.

  1. The target segment becomes the root.
  2. All depends on the target stay on the right of the hierarchy.
  3. All parents of the target become dependents of the target and are placed on the left in the hierarchy.

The target segment and its parents cannot be inserted or deleted in the secondary index view of the database. The secondary index view of the database is called a secondary data structure.

The database processing sequence is called the secondary processing sequence. To process using the secondary data structure, a PCB is used that defines the new structure. From the application programs perspective, there is no change in the accessing way.

Sparse Secondary Indexing:

IMS provides the capability to suppress the generation of secondary index segments. A value can be defined on the XDFLD statement which IMS will use when updating the secondary index.

If the contents of the secondary index field are equal to null parameter, no pointer segment will be created in the secondary index for this source segment. Another option is, write user exit and request its execution by coding EXTRN=user_exit on the XDFLD segment. IMS will then pass control to the user exit before updating the secondary index.

Secondary Index Options:

Secondary Index