The DELETE statement logically removes a record from a mass storage file.
DELETE filename-1 RECORD
[INVALID KEY imperative-statement-1]
[NOTINVALID KEY imperative-statement-2]
After the successful execution of a DELETE statement, the identified record has been logically removed from the file and can no longer be accessed.
The execution of a DELETE statement does not affect the contents of the record area associated with file-name-1 or the contents of the data item referenced by the data-name specified in the DEPENDING ON phrase of the RECORD clause associated with file-name-1.
The file referenced by file-name-1 must be open in the I-O mode at the time of execution of this statement.
For a file 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 runtime system logically removes from the file the record that was accessed by that READ statement.
For a file in random or dynamic access mode, except for an indexed file described with the DUPLICATES phrase in the RECORD KEY clause, the runtime system logically removes from the file the record identified by the contents of the key data item associated with file-name-1 .If the file does not contain the record specified by the key, the invalid key condition exists.For a relative file, the key data item is the relative key data item specified in the RELATIVE KEY phrase of the ACCESS MODE clause of the file control entry for file-name-1.For an indexed file, the key data item is the prime key data item specified in the RECORD KEY clause of the file control entry for file-name-1.
For an indexed file described with the DUPLICATES phrase in the RECORD KEY clause, the DELETE statement in the dynamic access mode is executed as if the file were in the sequential access mode and the DELETE statement in the random access mode is not allowed.
The execution of the DELETE statement causes the value of the specified file status data item, if any, associated with file-name-1 to be updated.
The file position indicator is not affected by the execution of a DELETE statement.
The INVALID KEY phrase and the NOT INVALID KEY phrase must not be specified for a DELETE statement that references a file which is in sequential access mode.
The INVALID KEY phrase must be specified for a DELETE statement that references a file which is not in sequential access mode and for which an applicable USE procedure is not specified. See the section on relative organization input-output or the section on indexed organization input-output for additional information on the invalid key condition and the use of the INVALID KEY and NOT INVALID KEY phrases.
The record to be deleted by the execution of the DELETE statement must not be locked by another run unit.For a shared input-output file, the run unit executing the DELETE statement should obtain a record lock by preceding the DELETE statement with a READ statement that locks the record to be deleted. If the run unit does not already hold a lock on the record to be deleted, the runtime system will attempt to obtain the lock.If the lock cannot be obtained because another run unit holds a lock on the record, subsequent action of the program is as described for the READ statement when attempting to lock a record already locked by another run unit.If the lock cannot be obtained because this run unit holds a lock on the record through another COBOL file-name, the DELETE statement is unsuccessful.See “File Locking ” and “ Record Locking ” for additional information on coordinating file updates in a shared file environment.
After successful execution of the DELETE statement, any record lock held by the rununit on the deleted record is released regardless of the record locking mode applicable to file-name-1.
In single record locking modes when a different record than the one being deleted is locked, that record lock is released upon execution of the DELETE statement.
In multiple record locking modes any record locks held by the run unit for file-name-1 are not released upon execution of the DELETE statement, except for the record lock on the deleted record.
DELETE Statement Examples
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.