Logically deletes a record from a KSAM file.
Operation Notes |
 |
Before calling BKDELETE, you can read the record to be deleted from the
KSAM file into the BASIC program. Using either BKREAD or BKREADBYKEY, read the record into variables named in the read
call. When BKDELETE is successfully executed, the record is marked
for deletion. If reuse is not specified, then a logically deleted
record is marked for deletion, but is not physically removed from
the file. Any connections between the record and key entries in
the index area are severed. The associated key entries are physically
deleted from the index area although the data record remains in
the data area. Data space is not reused in order to maintain the
chronological order of the file. Because BKDELETE requires that the record be both read and written,
you must open the file for update (access = 4) before calling this procedure.
After calling BKDELETE, you should check the status parameter to make sure that the delete was successful.
FCOPY can also be used to permanently remove any records that
were logically deleted with BKDELETE. When you use FCOPY to copy your KSAM file to a newly created KSAM file,
only active records are copied. Records marked for deletion are
dropped from the data area during the copy. The new file is more
compact, particularly if many records had been deleted from the
old file.
When access is shared, the call that positions the pointer
to the record to be deleted should be included in the same pair
of BKLOCK/BKUNLOCK calls as the call to BKDELETE. This ensures that no other user alters the record
position between the call that locates the record and the call that
deletes it.
Figure B-2 “Deleting a Record With BKDELETE” contains an example illustrating
the logical deletion of a record from a KSAM file.