Contents Index Searching for rows with find and lookup Transaction processing in UltraLite

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

Inserting updating, and deleting rows


To update a row in a table, use the following sequence of instructions:

  1. Move to the row you wish to update.

    You can move to a row by scrolling through the table or by searching, using find and lookup methods.

  2. Enter update mode.

    For example, the following instruction enters update mode on t:

    t.BeginUpdate();
  3. Set the new values for the row to be updated. For example:

  4. Execute the Update.

After the update operation the current row is the row that was just updated. If you changed the value of a column in the index specified when the Table object was opened, the current row is undefined.

UltraLite for C++ does not commit changes to the database until you commit them using conn->Commit(). For more information, see Transaction processing in UltraLite.

Caution    You can not update the primary key of a row: delete the row and add a new row instead.

Inserting rows 

The steps to insert a row are very similar to those for updating rows, except that there is no need to locate any particular row in the table before carrying out the insert operation. The order of row insertion into the table has no significance.

For example, the following sequence of instructions inserts a new row:

If you do not set a value for one of the columns, and that column has a default, the default value is used. If the column has no default, the following entries are added:

As for update operations, an insert is applied to the database in permanent storage itself when a commit is carried out. In utoCommit mode, a commit is carried out as part of the insert method.

Deleting rows 

The steps to delete a row are simpler than to insert or update rows. There is no delete mode corresponding to the insert or update modes. The steps are as follows:

  1. Move to the row you wish to delete.

  2. Execute the Table.elete() method.


Contents Index Searching for rows with find and lookup Transaction processing in UltraLite