Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 2 Jahren
Letzter Beitrag:
vor 2 Jahren
Beteiligte Autoren:
Michael Drechsel, Paulo Oliveira, Bart VDE, Fabrice Harari, Piet van Zanten

How to avoid users to modify the same record

Startbeitrag von Michael Drechsel am 22.02.2016 11:01

Hi Windevers,

I have to build a program where 2 or more users can save and modify the same record. That´s normal.
I use the method "the (last) winner takes it all" which means, that the last "saving" user overwrites the record changes from the concurrent user. Thats not the elegantest way ...

Whats your way to handle this ?

Antworten:

Hi Michael,

I think it's the only way.
It's the same way it goes in the physical world.

Regards,
Piet

von Piet van Zanten - am 22.02.2016 11:24
Hi everybody

when necessary, this is how I generally work, it's still last in wins, but at the FIELD level:

1. When OPENING the form, save the original record content
2. when saving the form (hmodify), read and block the record from disk
3.Do a comparison: original record/Form content. This gives me a list of fields that the user/process has modified in the form
4. Set in the file buffer ONLY the field that THIS FORM has modified

This methods keeps all changes made by somebody else if they are in different fields, and overwrite the fields if both side have modified them (last in wins)

The same system is used in WXReplication to replicate/transfer only the modified fields, so you have an example of the method I use (with halias) to do all that.

Best regards

von Fabrice Harari - am 22.02.2016 11:34
Hi Michael,

I add a "LastModification" field to my file. (datetime field). Every time I update a record, i also update this field with the current date/time.

A user want to change a record : I read it from the db and store the lastmodification in a local variabele.

Before I update a record, i read it again from the db and check if the lastmodification timestamp is the same as in my local variabele. Only then I perform the update, otherwise I give a message to the user that the record is changed and reload the record...

Regards,
Bart

von Bart VDE - am 22.02.2016 11:39
OK folks,

thx.

It looks like there is no built-in mechanism to make this with a 3 rows of code ....

von Michael Drechsel - am 22.02.2016 12:12
This problems can be managed by the Assisted management of HFSQL errors.
Check this help page:
http://doc.windev.com/en-US/?3044188&name=assisted_management_hfsql_errors#NOTE3_4

If you need to manage it yourself check the HOnError function.
http://doc.windev.com/en-US/?3044017

von Paulo Oliveira - am 22.02.2016 12:21
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.