INVALID KEY Phrase

The INVALID KEY phrase must be specified if an explicit or implicit EXCEPTION/ERROR procedure is not specified for this file.

When an attempt is made to write beyond the externally defined boundaries of the file, WRITE statement execution is unsuccessful and an EXCEPTION/ERROR condition exists.

For Relative files in Random or Dynamic access mode, an INVALID KEY condition exists when RELATIVE KEY specifies a record that already contains data.

For Indexed files in Random or Dynamic access mode, an INVALID KEY condition exists when the value of the key field in the record area equals that of an already existing record and DUPLICATES are not allowed.

For Indexed files in Sequential access mode, an INVALID KEY condition exists when the values of the primary record keys of successive records are not in ascending order.

IBM Extension

IBM Extension For a file that allows duplicate keys, the INVALID KEY condition exists only if the value of the record key is less than that for the previous record. End of IBM Extension

End of IBM Extension

When the invalid key condition is recognized, WRITE statement execution is unsuccessful, and the contents of the record are unaffected. Program execution proceeds according to the rules described under INVALID KEY Condition.