Using alternate indexes with ESDSs
Table 1 shows the use of alternate indexes and backward reading on an ESDS. The program has four files:
- BASEFLE
- Reads the base data set forward.
- BACKFLE
- Reads the base data set backward.
- ALPHFLE
- Is the alphabetic alternate index path indexing the children by name.
- SEXFILE
- Is the alternate index path that corresponds to the gender of the children.
There are DD statements for all the files. They connect BASEFLE and BACKFLE to the base data set by specifying the name of the base data set in the DSNAME parameter, and connect ALPHFLE and SEXFILE by specifying the names of the paths given in Table 1 and Table 1.
The program uses SEQUENTIAL files to access the data and print it first in the normal order, then in the reverse order. At the label AGEQUERY, a DIRECT file is used to read the data associated with an alternate index key in the unique alternate index.
Finally, at the label SPRINT, a KEYED SEQUENTIAL file is used to print a list of the females in the family, using the nonunique key alternate index path. The SAMEKEY built-in function is used to read all the records with the same key. The names of the females will be accessed in the order in which they were originally entered. This will happen whether the file is read forward or backward. For a nonunique key path, the BKWD option only affects the order in which the keys are read; the order of items with the same key remains the same as it is when the file is read forward.
At the end of the example, the Access Method Services DELETE command is used to delete the base data set. When this is done, the associated alternate indexes and paths will also be deleted.