Page 1 of 1
Optimistic locking - once again
Posted: Tue 11 Dec 2007 21:23
by mfg
I found this information in the previous messages:
>> How do I actually check whether the row has been updated by another user?
> Setting CheckRowVersion to True is enough.
I set CheckRowVersion to True in your example SdacDemo-> CachedUpdates, I added a TimeStamp field to the dbo.emp table, I opened 2 copies of sdacDemo and I was editing the same record in the same time. Nothing happend.
In that case should I get any error message or there is another way to catch this event ?
I use Sdac 4.30, Delphi 5, MsSql 2005.
Thanks for your help.
ZS
Posted: Thu 13 Dec 2007 08:52
by Antaeus
You should also set the DMLRefresh option to True.
Posted: Thu 13 Dec 2007 19:32
by jigesh
Antaeus wrote:You should also set the DMLRefresh option to True.
Where can I find the DMLRefresh option
Posted: Fri 14 Dec 2007 08:40
by Antaeus
You will find DMLRefresh within Options of TMSQuery, TMSTable, TMSStoredProc components.
Posted: Wed 02 Jan 2008 00:08
by mfg
I set DMLRefresh, CheckRowVersion to True and it works almost in the way I want, I've got an optimistic locking.
But I still have a little problem.
When 2 users edit the same record in the same time, one of them has got an error message "Update failed. Found 0 records".
I'wouldn't like to get this message - is it possible to get exactly message "error optimistic transaction" or something like this ?
I know that I can replace this message "Update failed. Found 0 records" to "error optimistic transaction" in PostError event, but I would like to avoid this situation, because this error message ("Update failed. Found 0 records") could be also cause by another database/sdac event (I find a lot of examples with this error message on this forum).
kind regards
ZS
Posted: Thu 03 Jan 2008 10:29
by Antaeus
It is better to change this message in your event handler. Just add a couple of conditions that verify values of DMLRefresh and CheckRowVersion options to be sure about the reason of the error.
side effect DMLRefresh = True (text field)
Posted: Fri 04 Jan 2008 23:33
by mfg
when I set DMLRefresh := True I got an error message when I make post:
"Bad parameter [my_text_field_name] Output parameters "text", "ntext", or image are not acceptable", if I use a text type field in TMSQuery.
How to avoid this error ?
I don't have this error if I Generate SQL - but in that case optimistic locking doesn't work

Posted: Wed 09 Jan 2008 16:14
by Antaeus
Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SDAC build.