Indexed files

When the KEY phrase is specified, the key data item used for the comparison is data-name-1.

When the KEY phrase is not specified, the key data item used for the EQUAL TO comparison is the prime record key.

When START statement execution is successful, the RECORD KEY or ALTERNATE RECORD KEY with which data-name-1 is associated becomes the key of reference for subsequent READ statements.

data-name-1
Can be any of the following items:
  • The prime RECORD KEY.
  • Any ALTERNATE RECORD KEY.
  • A data item within a record description for a file whose leftmost character position corresponds to the leftmost character position of that record key; it can be qualified. The size of the data item must be less than or equal to the length of the record key for the file.

Regardless of its category, data-name-1 is treated as an alphanumeric item for purposes of the comparison operation.

Note: If your key is numeric, you must specify the EQUAL TO condition, otherwise, unexpected results can happen.

The file position indicator points to the first record in the file whose key field satisfies the comparison. If the operands in the comparison are of unequal lengths, the comparison proceeds as if the longer field were truncated on the right to the length of the shorter field. All other numeric and alphanumeric comparison rules apply, except that the PROGRAM COLLATING SEQUENCE clause, if specified, has no effect.

When START statement execution is successful, the RECORD KEY with which data-name-1 is associated becomes the key of reference for subsequent READ statements.

When START statement execution is unsuccessful, the key of reference is undefined.