Using KSAM/XL and KSAM 64 (32650-90886)

234 AppendixB
BASIC/V Intrinsics
BKDELETE
BKDELETE
Logically deletes a record from a KSAM file.
CALL BKDELETE (
filenum
,
status
)
A call to BKDELETE logically deletes the record referenced by the logical record pointer. If
reuse is not specified, then a logically deleted record is marked for deletion, but is not
physically removed from the file. The connection between a data record marked for
deletion and the index area is severed.
When a file with deleted records is copied by FCOPY to a new KSAM file, records marked for
deletion by BKDELETE are not copied. This use of FCOPY provides a means to compact a file
in which many records have been marked for deletion but physically use space in the file.
To use BKDELETE, the file must be open in the access mode that allows update. If access is
shared, the file must also be opened with dynamic locking allowed (
lock
=1), and the file
must be locked by BKLOCK before records are deleted.
Parameters
filenum
A numeric variable containing the file number that identifies the file; this
number was returned by the last call to BKOPEN. It should not be altered
unless the file is closed with a successful call to BKCLOSE. (
Required
parameter
)
status
A four-character string variable to which is returned a code that indicates
whether or not the call to BKREWRITE was successful and if not, why not.
The first character is set to zero if the call succeeds, to another value if not.
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.