KEY condition

Indicates that an operation on a keyed record cannot be found.

Enabled/Disabled status

Always enabled.

Result

Causes the keyed record to be undefined, and the statement in which it appears to be ignored.

Raised

When a READ, REWRITE, or DELETE statement containing a KEY option cannot find a record with the specified key.

By a WRITE statement whose KEYFROM option specifies the key of an existing record.

Restriction

  • When a file is closed in an ON-unit for this condition, the results of normal return are undefined. Exit from the ON-unit with the closed file must be achieved with a GO TO statement.

Note

Just before the condition is signaled, the key value is assigned as the value to be returned by the ONKEY built-in function.

Syntax

KEY file-reference

Parameter

file-reference
A scalar file reference.

Example

The following is an example of the ON KEY(file-reference) statement.

ON KEY(OUTFILE) BEGIN;
   PUT SKIP LIST('INVALID KEY SPECIFIED FOR OUTFILE'); 
   PUT SKIP LIST('KEY WAS'||ONKEY());
END;

Other Information

Condition codes
50 - 58
Implicit action
Prints a message and raises the ERROR condition.
Normal return
Passes control to the statement immediately following the statement that raised KEY. Can also be undefined. See Restrictions above.