FairCom Corporation


F.95 DeleteVRecord


Delete current variable length ISAM record.

Short Name

DELVREC

TYPE

ISAM variable length record function

DECLARATION

COUNT DeleteVRecord(COUNT datno)

DESCRIPTION

DeleteVRecord deletes the current variable-length ISAM record for data file datno. If the data record is successfully deleted, DeleteVRecord updates all associated index files and returns the data record to the pool of available records for data file datno. After the deletion, the current ISAM record information stays unchanged! That is, even though the current record has just been deleted, the information in the current ISAM buffer is not disturbed so that you can scan in either direction through the data via the NextRecord or PreviousRecord routines. If key values reside in the variable-length portion of the record, the entire record must be retrieved, usually with ReReadVRecord.

In multi-user systems, invoke LockISAM(ctENABLE) before the ISAM routine which reads the record to be deleted. Delete frees low-level locks, but LockISAM(ctFREE) should be called after DeleteVRecord to clear the LockISAM state. See the example below.

DeleteVRecord does not shrink the files. c-tree Plus tracks and reuses deleted space before expanding the files. To remove all deleted space, compact the file using CompactIFile or CTCMPC.

RETURN

Value
Symbolic Constant
Explanation
0
NO_ERROR
Successful ISAM deletion. Current ISAM record remains unchanged.
4
KDEL_ERR
Could not delete key value. Has a previous ReWriteVRecord updated a key value AND not used separate buffers for the current ISAM record and the updated record?
48
FMOD_ERR
datno is assigned to a fixed-length data file.
57
DADV_ERR
Proper lock not found by the c-tree Server.
100
ICUR_ERR
No current ISAM record for data file.

See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

EXAMPLE

COUNT invfil, part_no_idx;
LONG part_key, plen;
struct invd {
LONG part_no;
TEXT part_name[120];
} recbuf;
plen = sizeof(recbuf);
printf("\nEnter part number to delete: ");
scanf("%ld",&part_key);
if (LockISAM(ctENABLE)
printf("\nError enabling locks = %d",isam_err);
else if GetVRecord(part_no_idx, &part_key, &recbuf, plen)
printf("\nError on GetRecord = %d",isam_err);
else if DeleteVRecord(invfil))
printf("\nCould not delete PART #%ld (%d %d).",
part_key, isam_err, isam_fil);
}
LockISAM(ctFREE);

SEE ALSO

DeleteRecord


FairCom Corporation
www.faircom.com