For each key or key segment, you must specify the start position, the length, and the key type, as defined below. Use a comma to separate field attributes and a comma before starting the description of a new key or key segment.
The following command specifies the key structure for an indexed file:
key (start, length, key-type, ...)
|start||is the offset of the record key (in bytes, starting at position 1).|
|length||is the size of the key in bytes.|
|key-type||is a code indicating the key type (see the list of key types below).|
You can specify one of the following key types in the KEY statement:
|PD||Primary key with duplicates allowed|
|AD||Alternate key with duplicates allowed|
|C||Key segment belonging to the primary or alternate key previously described|
The following sample describes the key structure for an indexed file with three keys:
key (502, 98, PD, 1, 18, A, 95, 18, AD, 337, 18, C)
In this example, the primary key allows duplicates. Its offset is 502 and its length is 98. The first alternate key has an offset of 1 and a length of 18. The second alternate key allows duplicates, and consists of two segments. The first segment starts at offset 95 and has a length of 18. The second segment starts at offset 337 and has a length of 18.
The AcuSort utility always sorts duplicate records in the order in which they are encountered in the input file, a process known as a stable sort.