Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Record Filters

c-treeDB allows users to define record filters using CTTable::FilterRecord(). When a filter is set, all records retrieved from a table are filtered against the given expression, and only records matching filter criteria are returned.

// set filter

try

{

ATable.FilterRecord("ZIPCODE == 12345");

}

catch (CTException &err)

{

printf("Filter record failed with error %d\n", err.GetErrorCode());

}

Only the user who sets the filter will have its records filtered. The filter is turned off when the table is closed, or when CTTable::FilterRecord() is called with an empty string as the filter expression. Only one filter may be active per table per user at once, so if a new filter is set to a table with an existing filter for the specific table, the old filter will be overridden.

// terminate filter

try

{

CTString empty;

ATable.FilterRecord(empty);

}

catch (CTException &err)

{

printf("Filter record failed with error %d\n", err.GetErrorCode());

}

Use CTTable::GetFilter() to retrieve the current filter expression. If no filters are active, CTTable::GetFilter() return an empty string. Use CTTable::IsFilteredRecord() to test if filters are active for a table.

When used in the client/server model, this feature has the potential to increase the performance since just the records matching the criteria will be returned, reducing the network traffic.

Record filters, when used in conjunction with sets provide the c-treeDB API with simple query capabilities.

TOCIndex