ILE COBOL Programmer's Guide

Processing Files with Descending Key Sequences

Files created with a descending keyed sequence (in DDS) cause the READ statement NEXT, PRIOR, FIRST, and LAST phrases to work in a fashion exactly opposite that of a file with an ascending key sequence. You can specify a descending key sequence in the DDS with the DESCEND keyword in positions 45 to 80 beside a key field. In descending key sequence, the data is arranged in order from the highest value of the key field to the lowest value of the key field.

For example, READ FIRST retrieves the record with the highest key value, and READ LAST retrieves the record with the lowest key value. READ NEXT retrieves the record with the next lower key value. Files with a descending key sequence also cause the START qualifiers to work in the opposite manner. For example, START GREATER THAN positions the current record pointer to a record with a key less than the current key.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]