You can search for records in a table using one of the CTRecord::Find(), CTRecord::FindTarget() and CTRecord::FindRowid() methods. FairCom DB API performs the find operations against the table indexes. When an index entry is found, the record data is loaded into the record buffer.
Before you can call CTRecord::Find(), you need to prepare the data you want to find:
// find record which product code is DISKETTE
CTRecord ARecord(ATable);
// clear the record buffer
ARecord.Clear();
// set the default index to "MyIndex"
ARecord.SetDefaultIndex("MyIndex");
// populate the 'product' field
ARecord.SetFieldAsString("product", "DISKETTE");
// find the record
try
{
if (ARecord.Find(CTFIND_EQ))
printf("Record found\n");
else
printf("Record not found\n");
}
catch (CTException &err)
{
printf("Record find failed with error %d\n", err.GetErrorCode());
}
CTRecord::Find(), CTRecord::FindTarget() and CTRecord::FindRowid() returns YES (true) if the record was found or NO (false) if the record was not found. These methods throw an exception if an error occurs.