Page 1 of 1

Lock with DataSnap

Posted: Fri 13 Dec 2013 18:39
by alissoncr
I am trying to use TIBCQuery with DataSnap. I set the Property LockMode in TIBCQuery to lmLockImmediate, in AfterOpen event I put "IBCQuery.Lock", but don't works. I do a test in application client-server and works normally. What's happening? Thanks!

Re: Lock with DataSnap

Posted: Mon 16 Dec 2013 09:48
by AndreyZ
When you set the TIBCQuery.LockMode property to lmLockImmediate, locking is performed when the user starts editing a record (you do not need to call the Lock method explicitly). It means that when you call the TIBCQuery.Edit method, the current record is locked on the server.
When you are using TClientDataSet, all changes are made on the client. TIBCQuery does not know anything about these changes until you call the TClientDataSet.ApplyUpdates method. When TClientDataSet.ApplyUpdates is called records are locked, updated, and unlocked.
If you want to lock records when using TClientDataSet, you should perform it yourself. You can use for this the SELECT FOR UPDATE WITH LOCK statement. For more information, please read the following articles:
http://www.firebirdsql.org/refdocs/lang ... elect.htmlhttp://www.firebirdsql.org/refdocs/lang ... hlock.html