Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to use transactions and locks

Note: This section is provided as a reference for the legacy CommDb component, which has been superceded by the CommsDat component. It is strongly recommended that users migrate to CommsDat. For implementations using CommsDat, see Transactions in the CommsDat API and Migration Guide.

[Top]


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