Hello,
I'm looking for use UniDac with new application that will work in different databases mainly, Sql server & Mysql but more will be add later.
I'm looking for best way how to detect the changed record from other users, for example if Both A & B open the same records and modify it, then B commit it's modification to the server, what happen if A try to commit his modification now?, is there any thing in UniDac to handle it? and what's the best way to do that?
one of solution I'm thinking about to use timestamps and then compare between the values before commit, but not sure if there are any better ways that will work smoothly with different databases.
Thanks
What's the best way to detect changed records by other users
TUniQuery and TUniTable have the LockMode property. You can set this property to lmOptimistic or lmPessimistic to prevent several users from editing the same record.
If LockMode = lmPessimistic, UniDAC locks the record when editing begins. Other users cannot modify the record while the first user is editing it. The record is unlocked after the Post or Cancel method of dataset is called.
If LockMode = lmOptimistic, UniDAC locks the record when Post is called. At this time UniDAC also gets the current values for this record from database. If the record was changed by another user, an exception is raised. So several users can edit the record at the same time but only one user can post the changes. Other users will get an exception.
If LockMode = lmPessimistic, UniDAC locks the record when editing begins. Other users cannot modify the record while the first user is editing it. The record is unlocked after the Post or Cancel method of dataset is called.
If LockMode = lmOptimistic, UniDAC locks the record when Post is called. At this time UniDAC also gets the current values for this record from database. If the record was changed by another user, an exception is raised. So several users can edit the record at the same time but only one user can post the changes. Other users will get an exception.