On 30 Jun 2011, at 1:48pm, Cecil Westerhof wrote: > I am writing a desktop application in which I want to have exclusive rights. > In this way I do not need to check if the data has changed when the user of > my program wants to change records. Is this possible?
You can open a transaction as BEGIN EXCLUSIVE <http://www.sqlite.org/lang_transaction.html> "After a BEGIN EXCLUSIVE, no other database connection except for read_uncommitted connections will be able to read the database and no other connection without exception will be able to write the database until the transaction is complete." This is how you do that sort of thing. So what you do is … 1) BEGIN EXCLUSIVE 2) Check the result code from step 1 and make sure you got the lock. 3) Do SELECTs to check the conditions for your data change and decide what to do. 4) If the results of step suggest changes, make them. 5) END It is extremely common to see programs where step 3 of the above is done before step 1. Obviously, from your question, you understand this. Note to SQLite experts: it's not clear to me at what level the exclusive lock is maintained on the file. If an app crashes in while an EXCLUSIVE lock is held, is the lock released ? Does this vary by platform ? Simon. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

