Previous Topic Next topic Print topic


The DELETE Statement

The DELETE statement logically removes a record from a mass storage file. It can be specified only for files with relative or indexed organization.

General Format


*

Syntax Rules

  1. The INVALID KEY phrase must not be specified for a DELETE statement which references a file in sequential access mode.
  2. The INVALID KEY phrase must be specified for a DELETE statement which references any file not in sequential access mode for which an applicable USE AFTER STANDARD EXCEPTION PROCEDURE is not specified.

    OSVSVSC2MF This rule is not enforced.

General Rules

  1. The associated file must be open in the I-O mode at the time of execution of this statement. (See the topic The OPEN Statement.)
  2. For files in sequential access mode, the last input-output statement executed for file-name-1 prior to the execution of the DELETE statement must have been a successfully executed READ statement. The operating system logically removes from the file the record that was accessed by that READ statement.
  3. For a file in random or dynamic access mode, the operating system logically removes from the file that record identified by the contents of a key data item associated with file-name. For a relative file, this key data item is the relative key and for an indexed file, it is the prime record key. If the file does not contain the record specified by the key, an INVALID KEY condition exists. (See the section The INVALID KEY Condition in the chapter Procedure Division.)
  4. After the successful execution of a DELETE statement, the identified record is logically removed from the file and can no longer be accessed.
  5. The execution of a DELETE statement does not affect the contents of the record area associated with file-name-1.
  6. The file position indicator is not affected by the execution of a DELETE statement.
  7. Execution of the DELETE statement causes the value of the specified FILE STATUS data item, if any, associated with the file-name to be updated. (See the topic I-O Status in the chapter Procedure Division.)
  8. Transfer of control following the successful or unsuccessful execution of the DELETE operation depends on the presence or absence of the optional INVALID KEY phrase

    ANS85 and NOT INVALID KEY phrase

    in the DELETE statement. (See the topic The INVALID KEY Condition in the chapter Procedure Division.)

  9. ANS85 The END-DELETE phrase delimits the scope of the DELETE statement. (See the section Explicit and Implicit Scope Terminators in the chapter Concepts of the COBOL Language.)
  10. MF When using DELETE, the record to be deleted must not be locked by another run unit.
  11. MF Following the successful execution of a DELETE statement, any record lock held by the run unit on the deleted record is released.
Previous Topic Next topic Print topic