Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic


Read the record with key less than target.

Short Name



ISAM function


COUNT GetLTRecord(FILNO keyno, pVOID target, pVOID recptr)


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

GetLTRecord() reads the last data record whose key value in keyno is less than, the key value pointed to by target into the buffer area pointed to by recptr. If successful, the record becomes the current ISAM record for the data file associated with keyno.

GetLTRecord() is frequently used to start searching a file via an index file that accepts duplicate keys. GetRecord() cannot be used since the index entries have suffixes appended. If index file keyno accepts duplicate entries, pad the target key value with null bytes to ensure that the entry with the smallest suffix is found. See the example for GetGTEKey().

An alternative to GetLTRecord() is LastInSet(), which reads the last data record whose key value matches the significant bytes in a target key; it is not necessary to pad the target when using LastInSet(). The main difference between GetLTRecord() and LastInSet() is that GetLTRecord() does not require any match with the target.

If the associated data file has variable-length records, then only the fixed-length portion (defined by dreclen in the original call to CreateIFile()) is actually read into the buffer pointed to by recptr. If you wish to read the entire variable-length record into the same or a different buffer, call ReReadVRecord() after GetLTRecord(). ReReadVRecord() requires the specific size of the buffer area so that it can check if sufficient space is available.

Notice that the data file number involved is not directly identified. The ISAM structure definition described in ISAM Functions (ISAM Database Technology, /doc/ctreeplus/30841.htm) contains the relationship between the index file number and the associated data file.



Symbolic Constant




Successful retrieval of current ISAM record.



recptr is NULL. No data file read performed.



Could not lock data record. No data file read performed.



No match for target key value found.

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


LONG cust_number;

FILNO keyno;

pTEXT recptr;


if (GetLTRecord(keyno,&cust_number,recptr))

printf("\nUnsuccessful search. Code = %d on file %d.",



No check is made to determine if recptr points to a region sufficiently large to accept a data record. If the area is too small, either code or data will be clobbered.

See also

GetGTEKey(), GetRecord(), LastInSet(), TransformKey(), CreateIFile(), ReReadVRecord()