You can search for records in a table using one of the ctdbFindRecord(), ctdbFindTarget() and ctdbFindRowid() functions. FairCom DB API performs the find operations against the table indexes, when an index entry is found, the record data is loaded from disk into the record handle's record buffer.
Before you can call ctdbFindRecord(), you need to prepare the data you want to find:
/* find record which product code is DISKETTE */
CTHANDLE hRecord = ctdbAllocRecord(hTable);
/* clear the record buffer */
ctdbClearRecord(hRecord);
/* set the default index to index 0 */
ctdbSetDefaultIndex(hRecord, 0);
/* populate the 'product' field (field 1)*/
ctdbSetFieldAsString(hRecord, 1, "DISKETTE");
/* find the record */
if (ctdbFindRecord(hRecord, CTFIND_EQ) != CTDBRET_OK)
printf("Record not found\n");
ctdbFindRecord(), ctdbFindTarget() and ctdbFindRowid() return CTDBRET_OK if a record is found or INOT_ERR (101) if no record is found. Any other return value indicates an error condition.