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

Chapter 6 57
Writing and Updating Record Data
Deleting a Record
Deleting a Record
The intrinsic FREMOVE effectively removes the current record from the KSAM file. When
executed, the 4-byte record header is modified, identifying the record as deleted. All key
entries pointing to this record are deleted from the indexes. Although the data still
occupies record space in the file, it is no longer possible to access the record through
standard read operations. Note that if deleted record space can be reused, this area can be
overwritten by a new record.
The FREMOVE intrinsic checks only the logical record pointer, not the physical record
pointer, to locate the record to be deleted. To delete a record located by its physical record
pointer, precede the call to the FREMOVE intrinsic with the FPOINT intrinsic. The FPOINT
intrinsic locates the record by its physical record pointer but sets both the logical and
physical record pointers.
NOTE
If you use the FREADDIR or FREADC intrinsic to locate the record, only the
physical record pointer is set. You may delete the wrong record because the
logical record pointer was not set by the read procedure.
Shared Access
If access to the file is shared with other processes, any of these intrinsics should be
preceded by FLOCK and FUNLOCK intrinsics. This controls access to the records and reduces
contention while a modification procedure is being performed. All pointer positioning, read
intrinsics, and writing, updating, and deletion procedures should be bounded by the FLOCK
and FUNLOCK intrinsics to guarantee that the proper record is updated or deleted.
NOTE
File locking keeps the file inaccessible to other users until the file is unlocked.
This could be a potential source of performance problems. A different file
structure may be more suitable for applications in a shared environment.