ctdbRecordSetOn
Enable a new record set. The target key is built from the contents of the record buffer.
Declaration
CTDBRET ctdbRecordSetOn(CTHANDLE Handle, NINT siglen)
Description
ctdbRecordSetOn() enables a new record set. The target key is built from the contents of the record buffer.
When record set is enabled, the record operations will be substituted by the set operations. This means that, when record set is enabled, operations like ctdbFirstRecord() will search for the first record in the set instead of the first record in the entire table.
Just one record set can be enabled for each record handle. If it is necessary to have more than one record set enabled at the same time, more than one record handle will be required. To disable and free an existing record set, use ctdbRecordSetOff().
If used in conjunction with filters (ctdbFilterRecord()), may behave as a simple query.
Returns
ctdbRecordSetOn() returns CTDBRET_OK if successful, or the c-tree error code on failure. The possible errors associated with ctdbRecordSetOn() are:
Example
/* display all records in set - no error checking */
void DisplayAll(CTHANDLE pRec)
{
NINT count = 0;
ctdbClearRecord(pRec);
ctdbSetDefaultIndexByName(pRec, "index_name");
ctdbSetFieldAsString(pRec, 0, "silva");
ctdbRecordSetOn(pRec, 5);
if (ctdbFirstRecord(pRec) == CTDBRET_OK)
{
do
{
count++;
PrintRecord(pRec);
}
while (ctdbNextRecord(pRec) == CTDBRET_OK);
}
printf("%d records in set\n", count);
}
See also
ctdbAllocRecord(), ctdbRecordSetOff(), ctdbFilterRecord()