RECORD KEY clause

The RECORD KEY clause (format 2) specifies the data item within the record that is the prime RECORD KEY for an indexed file. The values contained in the prime RECORD KEY data item must be unique among records in the file.

data-name-2
The prime RECORD KEY data item.

data-name-2 must be described within a record description entry associated with the file. The key can have any of the following data categories:

  • Alphanumeric
  • Numeric
  • Numeric-edited (with usage DISPLAY or NATIONAL)
  • Alphanumeric-edited
  • Alphabetic
  • External floating-point (with usage DISPLAY or NATIONAL)
  • Internal floating-point
  • DBCS
  • National
  • National-edited

Regardless of the category of the key data item, the key is treated as an alphanumeric item. The collation order of the key is determined by the item's binary value order when the key is used for locating a record or for setting the file position indicator associated with the file.

data-name-2 must not reference a variable-length data item. data-name-2 can be qualified.

If the indexed file contains variable-length records, data-name-2 need not be contained within the minimum record size specified for the file. That is, data-name-2 can exceed the minimum record size, but this is not recommended.

The data description of data-name-2 and its relative location within the record must be the same as those used when the file was defined.

If the file has more than one record description entry, data-name-2 need be described in only one of those record description entries. The identical character positions referenced by data-name-2 in any one record description entry are implicitly referenced as keys for all other record description entries for that file.

For files defined with the EXTERNAL clause, all file description entries in the run unit that are associated with the file must have data description entries for data-name-2 that specify the same relative location in the record and the same length.