Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

GetKey

Search index file for entry equal to target value.

Short Name

EQLKEY()

Type

Low-Level index file function

Declaration

LONG GetKey(FILNO keyno, pVOID target)

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

GetKey() searches index file number keyno for an entry equal to the key value pointed to by target.

See also Record Offsets Under Huge File Support.

Return

If GetKey() finds an exact match for target, then it returns the data record position associated with the entry. If an exact match is not found, or if an error occurs, then GetKey() returns a zero, and the global variable uerr_cod is set to the appropriate value. See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

LONG recbyt;

FILNO keyno;

TEXT target[11];


scanf("%10s %d",target,&keyno);

if (!(recbyt = GetKey(keyno,target))) {

if (uerr_cod)

printf("\nError while searching.");

else

printf("\nKey value not found.");

}

else

printf("\nKey value is in record at position %ld.", recbyt);

Limitations

FairCom DB will not pad the target key value. Ensure that target points to a properly formed key value. This function is not appropriate for indexes allowing duplicates. Use a function from below in that case.

See also

GetGTEKey(), GetGTKey(), GetLTEKey(), GetLTKey()

TOCIndex