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

Appendix A 187
COBOL Intrinsics
CKDELETE
CKDELETE
This procedure logically deletes a record from a KSAM file.
CALL "CKDELETE" USING
filetable, status
In order to logically delete records from a KSAM file, you can use the procedure CKDELETE.
If reuse is not specified, then a logically deleted record is marked for deletion, but is not
physically removed from the file. The deletion mark makes such a record inaccessible but
does not physically reduce the size of the file. The utility program FCOPY can be used to
compact a KSAM file by copying only active records, excluding deleted records, to a new
KSAM file.
CKDELETE deletes the record at which the logical record pointer is currently positioned.
Therefore, CKDELETE must be preceded by a call that positions the pointer.
Parameters
filetable
An 8 halfword record containing the number and name of the file, its
input/output type, access mode, and a code indicating whether the
previous operation was successful and if so what it was. (Refer to Filetable
Parameter discussion earlier in this section.)
status
One halfword (two 8-bit characters) set to a pair of values upon completion
of the call to CKDELETE indicating whether the call was successful and if
not, why not. (Refer to Status Parameter discussion earlier in this section.)
Operation Notes
In order to delete a record, you should first read the record into the working storage section
of your program with a call to CKREAD if in sequential mode, a call to CKREADBYKEY if in
random mode, or a call to either if in dynamic mode. CKDELETE can be called only if the file
is currently open for both input and output (input/output type =2). This allows the record
to be read into your program's data area and then written back to the file with the delete
mark. Following execution of CKDELETE, the deleted record can no longer be accessed.
If the file was opened for shared access with CKOPENSHR, you must lock the file with CKLOCK
before you can delete any records with CKDELETE. BecauseCKDELETE depends on the logical
record pointer, the call to CKLOCK should precede the call that positions the pointer. The
call to CKUNLOCK is then called after the call to CKDELETE. To illustrate, the sequence of
calls in shared access should be:
CKLOCK <---
to lock file
CKSTART or CKREADBYKEY <---
to position pointer
.
.
.
CKDELETE<---
to delete record at which pointer is positioned
CKUNLOCK<---
to unlock file