Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to modify the database content (DML)

The DML statements are those which modify the data content of the database, i.e. the INSERT, UPDATE and DELETE statements. These update SQL statements are effectively run within a transaction and are, therefore, atomic; either they complete fully or no changes are made to the database. There is no immediate functional equivalent provided by DBMS, though these operations can also be performed using an RDbView object with a suitable query and update code.

[Top]


Inserting rows

You can use the InsertL() function to insert a row:

_LIT(KSelect,"SELECT SupplierName from Suppliers");
_LIT(KSymLim,"Symbian Limited");
...
RDbView view;
view.Prepare(database,KSelect,view.EInsertOnly);
view.InsertL();
view.SetColL(1,KSymLim);
view.PutL();
view.Close(); 

Alternatively you may use the SQL INSERT statement:

_LIT(KSQLText,"INSERT INTO Suppliers (SupplierName) VALUES (Symbian Limited)");
...
database.Execute(KSQLText);

[Top]


Deleting rows

You can use the DeleteL() function to delete a row:

_LIT(KSelect,"SELECT SupplierName from Suppliers WHERE SupplierName=Symbian Limited");
...
database.Begin();
RDbView view;
view.Prepare(database,KSelect);
view.EvaluateAll();
while (view.NextL())
    view.DeleteL();
view.Close(); 
database.Commit();

Alternatively you may use the SQL DELETE statement:

_LIT(KSQLText,"DELETE FROM Suppliers WHERE SupplierName=Symbian Limited");
...
database.Execute(KSQLText);

Note: