Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbUpdateCriteria

Updates the criteria from the given CTResultSet handle.

Declaration

ctdbUpdateCriteria(CTHANDLE Handle, pTEXT LowValue, pTEXT HighValue)

Parameters:

  • Handle [IN] - Result Set Criteria handle
  • LowValue [IN] - New criteria low value
  • HighValue [IN] - New criteria high value

Description

The result set handle is allocated (ctdbAllocateResultSet()) for a specific table handle, and then it is possible to add one or more criteria (ctdbAddCriteria()). The criteria have a field to be checked against the table handle that owns the result set, one or two values (depending on the comparison operator) and the operator to be used. The operator can be on of: CTIX_EQ, CTIX_NE, CTIX_GT, CTIX_GE, CTIX_LE, CTIX_LT, CTIX_BET, CTIX_BET_IE, CTIX_BET_EI, CTIX_BET_EE or CTIX_NOTBET. When the result set has all the criteria added, it can be turned on or off (ctdbResultSetOnOff()) for any record handle that is allocated for the same table handle that owns the result set.

It is not possible to change the field nor operator as it may be required to change the index used.

Limitations

  • A result set can't be turned on for a record that is already filtered. And when a record has a result set turned on, it is not possible to add any other filter. This limitation may be relaxed in the future.
  • When a result set is changed (ctdbAddCriteria(), ctdbRemoveCriteria() and ctdbUpdateCriteria()), it must be re-applied to the record handle (ctdbResultSetOnOff()) to have these changed take effect..

Returns

CTDBRET_OK on success. CTDBRET error code on failure.

Example

CTHANDLE hResSet;

CTHANDLE hResSetCri;

/* Allocate a Result Set for Table */

if (!(hResSet = ctdbAllocateResultSet( hTable, "resSet1" )))

Handle_Error("Test_ResultSet1(); ctdbAllocateResultSet()");


/* Add a new criteria for the Result Set just allocated */

if (!(hResSetCri = ctdbAddCriteria( hResSet, hField0, "1002", NULL, CTIX_EQ )))

Handle_Error("Test_ResultSet1(); ctdbAddCriteria()");


/* Turn on the Result Set for the current record handle */

if (ctdbResultSetOnOff( hResSet, hRecord, YES, YES, CTLOC_NONE ) != CTDBRET_OK)

Handle_Error("Test_ResultSet1(); ctdbResultSetOnOff()");


/* Display records on the Result Set */

Display_Records(hRecord);


/* Release Result Set handle */

ctdbFreeResultSet( hResSet );

See also

TOCIndex