COBOL Manual for TNS/E Programs (H06.03+)

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-43
DELETE
imperative-stmt-2
is an imperative statement to be executed (after a declarative procedure) when no
exception or an exception other than the invalid-key condition arises during the
delete operation.
END-DELETE
ends the scope of the DELETE statement and makes it a delimited-scope
statement. If you omit END-DELETE but include the INVALID KEY or NOT
INVALID KEY phrase, the DELETE statement is a conditional statement and ends
at the next period separator.
Usage Considerations:
I-O Status Codes
If the file being closed has an associated file-status data item, the DELETE
statement assigns it an appropriate I-O status code. The possible I-O status codes
and their meanings are:
When the deletion is successful or the invalid-key condition occurs, these items are
not affected:
°
Record area
°
Data item specified in the DEPENDING phrase of the RECORD clause,
specifying the length of the record
°
Key of reference
°
File position indicator
Record Deleted When File Access Mode is Sequential
If the file’s access mode is sequential and the last operation performed on the file
was a successful READ statement, then DELETE logically removes from the file
the record that the READ statement retrieved. If the last operation performed on
the file was not a successful READ statement, DELETE terminates with I-O status
code “43.”
I-O Status Code Meaning
“00” The delete operation was successful.
“23” The designated record does not exist.
“30” The delete operation failed due to causes outside of COBOL. The
specified record might or might not have been deleted. The file
position indicator might be undefined.
“43” The delete operation failed because the last input-output
statement executed for the file (which is in the sequential access
mode) was not a successfully executed READ statement.
“49” The file was not open in the I-O mode or was not opened by an
HP COBOL program.