Summary -

In this topic, we described about the INVALID KEY Phrase with detailed example.

Both the INVALID KEY phrase and an applicable EXCEPTION/ERROR procedure can be omitted. The invalid key condition can occur during execution of a START, READ, WRITE, REWRITE, or DELETE statement.

When an invalid key condition occurs, the input-output statement that causes the condition is unsuccessful. If the INVALID KEY phrase is specified and condition occurred, control is transferred to the INVALID KEY imperative statement.

If the INVALID KEY phrase is not specified in the input-output statement for a file and an applicable EXCEPTION/ERROR procedure exists, that procedure is executed. The NOT INVALID KEY phrase if specified, is ignored.

Both the INVALID KEY phrase and the EXCEPTION/ERROR procedure can be omitted.If the invalid key condition does not exist, the INVALID KEY phrase is ignored if specified.