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.
After you perform a Delete operation, a later Get Next or Get Previous operation must use the same key number as the last operation that established logical position. If you use another value, the MicroKernel Engine returns Status Code 7.
The MicroKernel Engine does not allow Delete operations after a Get Key operation (+50). Before the MicroKernel Engine 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 MicroKernel Engine 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 MicroKernel Engine cannot perform its passive concurrency conflict checking without the compare. When the Delete fails, the MicroKernel Engine returns Status Code 8.
Result
If the Delete operation is successful, the MicroKernel Engine 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 MicroKernel Engine returns one of the following status codes:
Delete operations never reduce file size. Empty Space created by deletion of records is reused when records are added in the future. Recovering disk space can only be done by recreating 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.