Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

SetRecord

Resets the current ISAM record.

Short Name

SETCURI()

Type

ISAM function

Declaration

COUNT SetRecord(FILNO datno, LONG recbyt, pVOID recptr, VRLEN datlen);

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

c-tree maintains the record number of the current ISAM record for each data file, as well as an image of the key buffer. There may be times when you want to reset the current ISAM record. For instance, if you want to return to a particular point in the file and index in order to continue a sequential scan of the file. By calling SetRecord(), you can set the current record offset of file datno to the value in recbyt.

recptr points to a record image. If datlen is zero, recptr should point to a complete fixed-length record, or the fixed portion of a variable-length record. Otherwise, datlen indicates the size of the information pointed to by recptr.

If recptr is NULL, only the record position is updated. This is useful when SetRecord() is used to prepare for ReReadRecord(), or ReReadVRecord(), to reread the current ISAM record.

Return

Value

Symbolic Constant

Explanation

22

FNUM_ERR

File number is out of range.

26

FACS_ERR

File number is not assigned to a file in use.

47

FINT_ERR

c-tree has not been initialized.

48

FMOD_ERR

datno is not assigned to a data file.

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

Example

FILNO datno, keyno;

LONG custno, recpos;

TEXT savbuf[128], buffer[128];


printf("\nEnter customer number: ");

scanf("%ld",&custno);

if (FirstInSet(keyno, &custno, savbuf, 4))

printf("\nCould not read customer record");

else{

recpos = CurrentFileOffset(datno);

process_more_records_in(buffer);

/* restore original record as current ISAM */

SetRecord(datno,recpos,savbuf,128L);

}

Limitations

The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSETHGH() and ctGETHGH() functions to set or get the high-order 4 bytes of the file offset. See also Record Offsets Under Huge File Support.

See also

ReReadRecord(), ReReadVRecord(), ctSETHGH(), ctGETHGH(), CurrentISAMKey(), TransformKey()

TOCIndex