Applies to relative and indexed file organization
Function
A DELETE statement logically removes a record from a disk storage file.
Format
DELETE file-name RECORD
[INVALID KEY imperative-statement-1]
[NOT INVALID KEY imperative-statement-2]
[END-DELETE]
Syntax rules
The INVALID KEY phrase must not be specified for a DELETE statement which references a file in sequential access mode.
If a file is not in sequential access mode and no applicable USE procedure has been specified, the INVALID KEY phrase is mandatory.
General rules
The file referenced in the DELETE statement must be open in I-O mode during the execution of this statement (see also "OPEN statement").
After successful execution of the DELETE statement, the identified record is deleted from the file.
Execution of a DELETE statement does not affect the contents of the record area associated with the file or the content of the data item referenced by the data-name specified in the DEPENDING ON phrase of the RECORD clause.
For a file in sequential access mode, the last input/output statement entered prior to the DELETE statement must be a successfully completed READ statement. The RELATIVE KEY (for relative file organization) or RECORD KEY (for indexed file organization) must not be changed between reading and deletion. In this case, the DELETE statement causes the record read by the preceding READ statement to be logically removed from that file.
After execution of the DELETE statement, the contents of the data item specified in the FILE STATUS clause for the file are updated (see "FILE STATUS clause").
Continuation of the execution of the DELETE statement depends on whether the INVALID KEY or NOT INVALID KEY phrase is specified (see "Invalid key condition").