Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbFindRecord

Find a record using the FindMode as the find strategy.

Declaration

CTDBRET ctdbFindRecord(CTHANDLE Handle, CTFIND_MODE FindMode)

Description

ctdbFindRecord() finds a record in the table associated with the record handle, using the FindMode strategy. The record data is retrieved from disk into the record handle’s record buffer and the current record is set to that record. Note that if session-wide record locking is enabled, this function will also lock the record it retrieves.

  • Handle [in] the record handle.
  • FindMode [in] the mode to use to look for the record in the table. The find modes are listed in c-treeDB API definitions.

Before using ctdbFindRecord(),

  • clear the record buffer with ctdbClearRecord()
  • select the index to search with ctdbSetDefaultIndex()
  • set search target values with one or more of the ctdbSetFieldAs...() functions
  • call ctdbFindRecord()

Note: The FindMode CTFIND_EQ requires that the target contains values for all segments that compose the index and the index cannot allow duplicates.

Use ctdbFirstRecord() to retrieve the first record of a table, ctdbNextRecord() to retrieve the next record of a table, ctdbPrevRecord() to retrieve the previous record of a table, and ctdbLastRecord() to retrieve the last record of a table. Use ctdbFindTarget() to find a record using a given target key.

Returns

ctdbFindRecord() returns CTDBRET_OK if the record was found, or INOT_ERR (101) if no record was found. Any other return value indicates an error condition (c-treeDB API error).

Example


ctdbClearRecord(hRec);

ctdbSetDefaultIndex(hRec, 1);

ctdbSetFieldAsString(hRec, ctdbGetFieldNumberByName(hRec, "Name"), name);

ctdbFindRecord(hRec, CTFIND_EQ);


See also

ctdbAllocRecord(), ctdbFirstRecord(), ctdbNextRecord(), ctdbPrevRecord(), ctdbLastRecord(), ctdbFindTarget(), ctdbClearRecord(), ctdbSetDefaultIndex()

TOCIndex