Contents Index Accessing the values of the current row Inserting updating, and deleting rows

UltraLite C++ User's Guide
  Understanding UltraLite Development
    Accessing and manipulating data with the Table API

Searching for rows with find and lookup


UltraLite has several modes of operation when working with data. The Table object has two sets of methods for locating particular rows in a table:

Both sets are used in a similar manner:

  1. Enter find or lookup mode.

    The mode is entered by calling a method on the table object. For example.

    t.FindBegin();
  2. Set the search values.

    You do this by setting values in the current row. Setting these values affects the buffer holding the current row only, not the database. For example:

    ULValue lname_col = t->GetSchema()->GetColumnID( "lname" );
    ULValie v_lname( "Kaminski" );
    t.Set( lname_col, v_lname );

    Only values in the columns of the index are relevant to the search.

  3. Search for the row.

    Use the appropriate method to carry out the search. For example, the following instruction looks for the first row that exactly matches the specified value in the current index:

    tCustomer.FindFirst();

    For multi-column indexes, a value for the first column is always used, but you can omit the other columns and you can specify the number of columns as a parameter to the find method.

  4. Search for the next instance of the row.

    Use the appropriate method to carry out the search. For a find operation, FindNext() locates the next instance of the parameters in the index. For a lookup, MoveNext() locates the next instance.

For more information, see the following classes in the API Reference:


Contents Index Accessing the values of the current row Inserting updating, and deleting rows