DELETE, DELETEU |
|
|
The DELETE statement deletes a record from an open file. The DELETEU statement is similar but it preserves locks.
Format
DELETE file.var, record.id {ON ERROR statement(s)} DELETEU file.var, record.id {ON ERROR statement(s)}
where
The specified record is deleted from the file. No error occurs if the record does not exist.
If the process performing the DELETE had a read or update lock on the record, the lock is released. The DELETEU statement preserves any lock. Within a transaction, the lock is retained until the transaction terminates and then released regardless of which statement is used. Attempting to delete a record in a transaction will fail if the process does not hold an update lock on the record or the file.
The ON ERROR clause is executed for serious fault conditions such as errors in a file's internal control structures. It is also executed if the delete operation is disallowed by a pre-delete trigger function associated with the file. The STATUS() function will return an error number. If no ON ERROR clause is present, an abort would occur.
Example
DELETE STOCK, ITEM.ID
This statement deletes the record whose id is in ITEM.ID from the file associated with file variable STOCK. |