Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

DeleteVRecord

Delete current variable-length ISAM record.

Short Name

DELVREC()

Type

ISAM variable-length record function

Declaration

COUNT DeleteVRecord(FILNO datno)

Description

In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering

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. FairCom DB tracks and reuses deleted space before expanding the files. To remove all deleted space, compact the file using CompactIFile().

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 FairCom Server.

100

ICUR_ERR

No current ISAM record for data file.

See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

FILNO 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, NextRecord, PreviousRecord, ReReadVRecord, LockISAM,
CompactIFile

TOCIndex