Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ReReadVRecord

Reread variable-length ISAM data record.

Short Name

REDVREC()

Type

ISAM variable-length record function

Declaration

COUNT ReReadVRecord(FILNO datno,pVOID recptr, VRLEN varlen)

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

ReReadVRecord() reads the current variable-length ISAM record for data file datno into the buffer area pointed to by recptr. If varlen, the size of the buffer pointed to by recptr, is not large enough for the variable-length record, ReReadVRecord() returns an error. ReReadVRecord() is used to read the entire variable-length record after the fixed-length portion is read via one of the fixed-length ISAM search routines (e.g., FirstInSet() instead of FirstInVSet()).

To ensure varlen is large enough, call VRecordLength() before calling ReReadVRecord(). VRecordLength() returns the actual length of the record. If the existing buffer is not large enough, allocate a new, larger buffer before calling ReReadVRecord().

Note: No check is actually made to be sure that the region pointed to by recptr is in fact as large as varlen indicates. It is up to the application to ensure that varlen accurately specifies the size of the area pointed to by recptr.

As of c-tree V8.14, c-tree sets the current ISAM position after a record is added such that the next or previous record can be read without having to re-read the record just added. Prior to V8.14, the current ISAM position was not set to a newly-added record and an INOT_ERR (101) error would result if you tried to read either the next or previous record.

See also Record Offsets Under Huge File Support.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful read.

33

DNUL_ERR

recptr is NULL.

35

SEEK_ERR

lseek() failed while preparing for read.

36

READ_ERR

Operating system could not execute read.

48

FMOD_ERR

datno is not assigned to a variable-length data file.

100

ICUR_ERR

No current ISAM record for file datno.

153

VBSZ_ERR

varlen < actual record length.

154

VRCL_ERR

Variable-length record is zero bytes long.

158

VFLG_ERR

Variable-length record is not marked as active.

159

VPNT_ERR

recbyt is zero.

See c-tree Error Codes for a complete listing of valid c-tree error values.

Example

FILNO datno, keyno;

VRLEN cur_bufsiz = 128, varlen;

pTEXT recptr;

LONG part_number;


recptr = calloc(1, cur_bufsiz));

if (FirstRecord(keyno, recptr)) == NO_ERROR) {

if ((varlen = VRecordLength(datno)) > cur_bufsiz) {

free(recptr);

recptr = calloc(1,varlen));

cur_bufsiz = varlen;

}

if (ReReadVRecord(datno,recptr,varlen))

printf>("\nCould not reread record (%d).", isam_err);

}

See also

ReadVData(), ReReadRecord(), VRecordLength(), WriteVData()

TOCIndex