Delete (4)
The Delete operation (B_DELETE) removes an existing record from a file. The space that the deleted record occupied is then available for inserting new records.
Parameters
 
Prerequisites
Procedure
1
2
Details
The Delete operation is not a valid operation if performed immediately after an extended Get or extended Step operation.
When performing a Delete operation immediately following a Get operation, do not change the Key Number that the Get operation returns. If you do, the transactional interface deletes the record successfully; however, it returns Status Code 7 on the first Get operation performed after the deletion.
The transactional interface does not allow Delete operations after a Get Key operation (+50). Before the transactional interface performs a Delete operation, it compares the current usage count of the data page it intends to modify with the usage count of the data page when the record was read. To obtain the usage count, the transactional interface must read the data page.
Because the Get Key operation does not read the data page, no usage count is available for comparison on the Delete. The Delete fails because the transactional interface cannot perform its passive concurrency conflict checking without the compare. When the Delete fails, the transactional interface returns Status Code 8.
Result
If the Delete operation is successful, the transactional interface removes the record from the file, releases the record lock (if one existed for the deleted record), and adjusts all key indexes to reflect the deletion.
If the Delete operation is unsuccessful, the transactional interface returns one of the following status codes:
Delete operations never reduce file size. Empty Space created by deletion of records is re-used when records are added in the future. Recovering disk space can only be done by re-creating the file and inserting all the records into it.
Positioning
The Delete operation destroys the complete physical location information and the logical current record position but does not change the physical and logical positions of either the next record or the previous record.