Function
The RECORD KEY clause defines the primary record key used for accessing the records in an indexed file.
Format
RECORD KEY IS data-name
Syntax rules
data-name must be an alphanumeric or national data item defined within a record description entry. This record description entry must be assigned to the file-name to which the RECORD KEY clause is subordinate.
data-name may be any fixed-length item within the record. The item may be 1 through 255 bytes in length. The data-name may be qualified, but not indexed or subscripted.
data-name may not reference a group item which contains an element with an OCCURS clause with DEPENDING ON phrase.
If the file contains variable-length records, the record key must be contained in the first x bytes in the record, where x is the minimum record length for this file (see section "RECORD clause"). This means that the length of the record key must be fully included within the shortest record.
General rules
Record key values must be unique for all records within the file.
The data description and the relative position within a record of data-name must be the same as those specified when the file was created. The number of alternate record keys must match the number specified when the file was created.
If there are several record description entries in a file, data-name needs to be described in only one of these entries. The position of the key field in the record defined by data-name is used implicitly for all keys in the other record description entries.
If the RECORD KEY clause refers to an external file, the equivalent RECORD KEY clause must be specified in any program that uses this external file; in particular, the length and position of the key fields in the record must be defined so as to be consistent.