10.3 DELETE Statement

The DELETE statement deletes records from relative files. It takes the following form:

DELETE ([UNIT=]u, [REC=r] [,ERR=s] [,IOSTAT=ios])
u
Is the number of the logical unit containing the record to be deleted.
r
Is the positional number of the record to be deleted.
s
Is the label of an executable statement that receives control if an error condition occurs.
ios
Is an integer scalar memory reference that is defined as a positive integer if an error occurs and zero if no error occurs.

Rules and Behavior

In a relative file, DELETE deletes the direct access record specified by r. If REC=r is omitted, the current record is deleted. When the direct access record is deleted, any associated variable is set to the next record number.

The DELETE statement logically removes the appropriate record from the specified file by locating the record and marking it as a deleted record. It then frees the position formerly occupied by the deleted record so that a new record can be written into that position.


Note
You must specify the compiler option VMS for future READs to detect that a record has been deleted.

In the following example, the fifth record in the file connected to logical unit 10 is deleted from the file:

DELETE (10, REC=5)

Consider that the following statement is specified:

DELETE (UNIT=9, REC=10, IOSTAT=IOS, ERR=20)

The tenth record in the file connected to unit 9 is deleted. If an error occurs, control is transferred to the statement labeled 20, and a positive integer is stored in variable IOS.

For More Information:

For details on an alternative form for DELETE with relative files, see Section A.12.


Previous Page Next Page Table of Contents