DELETE Statement

The DELETE statement removes a record from an indexed or relative file. For indexed files, the key may then be reused for record addition. For relative files, the space is then available for a new record with the same RELATIVE KEY value.

When the DELETE statement is executed, the associated file must be open in I-O mode.

Read syntax diagramSkip visual syntax diagram
DELETE Statement - Format

>>-DELETE--file-name--+--------+-------------------------------->
                      '-RECORD-'   

>--+--------------------------------------+--------------------->
   |        (1)                           |   
   '-FORMAT------+----+--+-identifier-1-+-'   
                 '-IS-'  '-literal-1----'     

>--+----------------------------------------+------------------->
   |              (1)                       |   
   '-NULL-KEY-MAP------+----+--identifier-2-'   
                       '-IS-'                   

>--+------------------------------------------+----------------->
   '-INVALID--+-----+--imperative-statement-1-'   
              '-KEY-'                             

>--+----------------------------------------------+------------->
   '-NOT INVALID--+-----+--imperative-statement-2-'   
                  '-KEY-'                             

>--+------------+----------------------------------------------><
   '-END-DELETE-'   

Notes:
  1. IBM® Extension
file-name
Must be defined in an FD entry in the Data Division and must be the name of an indexed or relative file.

After successful execution of a DELETE statement, the record is logically removed from the file and can no longer be accessed. Execution of the DELETE statement does not affect the contents of the record area associated with the file-name (or the content of the data item referenced by the data-name specified in the DEPENDING ON phrase of the RECORD clause associated with file-name).

If the FILE STATUS clause is specified in the File-Control entry, the associated status key is updated when the DELETE statement is executed.

The file position indicator is not affected by the processing of the DELETE statement.