Coding INVALID KEY phrases
You can include an INVALID KEY
phrase
in READ
, START
, WRITE
, REWRITE
,
and DELETE
statements for VSAM indexed
and relative files. The INVALID KEY
phrase is given
control if an input or output error occurs due to a faulty index key.
About this task
You can also include the INVALID KEY
phrase
in WRITE
requests for QSAM files, but the phrase
has limited meaning for QSAM files. It is used only if you try to
write to a disk that is full.
Use the FILE STATUS
clause
with the INVALID KEY
phrase to evaluate the status
key and determine the specific INVALID KEY
condition.
INVALID KEY
phrases differ from ERROR
declaratives
in several ways. INVALID KEY
phrases:
- Operate for only limited types of errors.
ERROR
declaratives encompass all forms. - Are coded directly with the input or output statement.
ERROR
declaratives are coded separately. - Are specific for a single input or output operation.
ERROR
declaratives are more general.
If you code INVALID KEY
in a statement
that causes an INVALID KEY
condition, control is
transferred to the INVALID KEY
imperative statement.
Any ERROR
declaratives that you coded are not performed.
If you code a NOT INVALID KEY
phrase, it is performed
only if the statement completes successfully. If the operation fails
because of a condition other than INVALID KEY
, neither
the INVALID KEY
nor the NOT INVALID KEY
phrase
is performed. Instead, after the program performs any associated ERROR
declaratives,
control passes to the end of the statement.