UltraLite.NET User's Guide
Understanding UltraLite Development
Accessing and manipulating data with the Table API
To update a row in a table, use the following sequence of instructions:
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.
Enter update mode.
For example, the following instruction enters update mode on t:
t.BeginUpdate();
Set the new values for the row to be updated. For example:
t.SetInt( id , 3);
Execute the Update.
t.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.
By default, UltraLite.NET operates in autocommit mode, so that the update is immediately applied to the row in permanent storage. If you have disabled autocommit mode, the update is not applied until you execute a commit operation. 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. |
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:
t.InsertBegin(); t.SetInt( id, 3 ); t.SetString( lname, "Carlo" ); t.Insert();
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:
For nullable columns, NULL.
For numeric columns that disallow NULL, zero.
For character columns that disallow NULL, an empty string.
To explicitly set a value to NULL, use the setNull method.
As for update operations, an insert is applied to the database in permanent storage itself when a commit is carried out. In AutoCommit mode, a commit is carried out as part of the insert method.
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:
Move to the row you wish to delete.
Execute the Table.Delete() method.