Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Descending Key Segment Values

Any of the key segment modes presented in the previous section can be modified to force the key segment to be collated in descending, (instead of ascending), order by adding a value of 16 to the mode or by OR-ing the mode with the symbolic constant DSCSEG.

For example, a segment mode of two will cause the following key values to be sorted in ascending order:

"ABC"

"BCD"

"DEF"

A segment mode of 18, (2 + 16), stores the key values in descending order:

"DEF"

"BCD"

"ABC"

Because this modification is performed at the segment level, it is possible to have some segments collating in ascending order while others collate in descending order in the same key value. For example, a customer order key may be stored in increasing order by customer number, while orders for the same customer are stored in descending order by date. This would make the most current orders come first for each customer.

Remember the information about preparing keys for searches discussed earlier in IMPORTANT - Key Value Assembly.

TOCIndex