Lock with DataSnap

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
alissoncr
Posts: 1
Joined: Fri 11 Oct 2013 18:37

Lock with DataSnap

Post by alissoncr » Fri 13 Dec 2013 18:39

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!

AndreyZ

Re: Lock with DataSnap

Post by AndreyZ » Mon 16 Dec 2013 09:48

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

Post Reply