Deleting records from a file
To remove an existing record from an indexed or relative
file, open the file as I-O
and use the DELETE
statement.
You cannot use DELETE
for a sequential or line-sequential
file.
About this task
If ACCESS
IS SEQUENTIAL
, the record to be deleted must first be read
by the COBOL program. The DELETE
statement removes
the record that was just read. If the DELETE
statement
is not preceded by a successful READ
, the record
is not deleted, and the file status key is set to 92.
If ACCESS
IS RANDOM
or ACCESS IS DYNAMIC
, the record
to be deleted need not be read by the COBOL program. To delete a record,
move the key of the record to the RECORD KEY
data
item, and then issue the DELETE
.
Check the
file status key after each DELETE
statement.