Database APIs which can return a value telling that that the database is locked

Login to reply to this topic.
Wed, 2007-09-05 07:35
Joined: 2007-08-22
Forum posts: 3

Hi,
I am working on Symbian database that can be shared using the database server. I was trying to find out the APIs which can return a Symbian error code that can tell that the database is locked. I could find that Begin and Execute can return KErrLocked. What other APIs can return same or similar error code so that I can set up the notifier and be notified when the locks are removed.

Any help will be great.

Regards,
Sumit


Thu, 2007-09-13 07:27
Joined: 2006-10-05
Forum posts: 80
Re: Database APIs which can return a value telling that that the

Hi Sumit,

The other database APIs that let you know if database is locked is InTransaction() . You can check out the documentation for this API in the Class RDbDatabase.

Also on performing any other database operation like update/delete using UpdateL() or DeleteL(), if the operation is enclosed withing a TRAP harness, you will get a KErrLocked error.

Further, if you perform such an update or delete operation using a view and execute an SQL query in the database using Execute() function of Class RDbDatabase, it will return KErrLocked error if the database is locked.

Hope this helps.. Smiling

Fri, 2007-09-14 07:02
Joined: 2007-08-22
Forum posts: 3
Re: Database APIs which can return a value telling that that the

Hi,
Thanks for the information. So basically if I am using SQLs to manipulate with the database then Execute() returns KErrLocked and Begin() in case of Transaction.

InTransaction() returns boolean which means that it just tells whether the database in transaction or not.

Regards,
Sumit

Fri, 2007-09-14 08:42
Joined: 2006-10-05
Forum posts: 80
Re: Database APIs which can return a value telling that that the


Yes, InTransaction() does return boolean which means that it just tells whether the database in transaction or not.

So from this, you can make sure that whenever you are doing any update/delete/insert operation, you should always start an explicit transaction using Begin().
Then whenever you check InTransaction() for another simultaneous database operation, you are sure that currently database is locked since you have begun an explicit transaction somewhere else in your application.

So InTransaction() returning ETrue implies that database is locked.

And also as i earlier mentioned, TRAPping the database update APIs will also give you KErrLocked error.

  • Login to reply to this topic.