Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to use transactions and locks


Writing to the database

To change two columns of the current record, the sequence of calls would be coded:

BeginTransaction()        //Gets a shared read-lock on the database
UpdateRecord()
WriteUintL()            //Tries to upgrade to an exclusive write-lock
WriteTextL()
PutRecordChanges()
CommitTransaction()    //Unlocks database

[Top]


Reading from the database

To read more than one record and guarantee that the content of each record does not change between the read operations, wrap the set of read operations within a transaction.

BeginTransaction()        //Gets a shared read-lock on the database
ReadUintL()
GotoNextRecord()
ReadUintL()
CommitTransaction()    //Unlocks database