Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know if someone changed one or more fields
Message
From
26/03/2024 14:23:47
 
 
To
26/03/2024 13:45:50
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01687771
Message ID:
01687780
Views:
34
>>>>>>Is there a way for user "A" to know if any other user modified the same record (the same or other fields), and for the application to know and notify the user of those changes? Then, user "A" decides whether or not to overwrite those previous changes.
>>>>>
>>>>>Check out these functions: GetNextModified(), GetFldState(), CURVAL(), and OLDVAL()
>>>>
>>>>Not sure oldval() would be enough, these functions compare the edited values against the last read values. The problem in this case is the value at the server, which is unknown at save time. One possible solution would be to have the wheretype=1 (if I remember correctly*), the one which compares not only the key against the serverside record, but also the oldval() values against it. So if the old value of the field is not the same as the value on server, the update will fail... and that's where it gets complicated, what to do then. One way would be to retrieve the record in its current state from the server into a separate cursor, then show the differences between it and the values we tried to save (ouch, lots of code to write), show them onscreen (more code...) and let the user decide what to do. If it's a text field, try to merge perhaps (ouch squared).
>>>>
>>>>* nope, it's 3
>>>>3 or DB_KEYANDMODIFIED (from FOXPRO.H) - Includes the primary fields specified by the KeyFieldList property and other modified fields.
>>>
>>>Thanks Dragan, I'll give it a try.
>>
>>Hi Dragan, I tried your advice, but it didn't help me, then I changed the remote view's "SQL WHERE clause includes" criteria to 2 or DB_KEYANDUPDATABLE (from FOXPRO.H) and when I tried to save my changes it threw me an error message "Update conflict in cursor 'MyRemoteView'".
>>
>>Now, I still don't know how to know the field(s) changed by the other user. I tried with AERROR(myArray), it has 1 row, first column just gives an error number which is 1585, the second column says "Update conflict in cursor 'myRemoteView'.", third column has the name of my remote view, rest of columns are filled with 0 and nulls.
>
>You've just got to the point where it got complicated, see above. You now have just a way to detect that the serverside record has changed meanwhile, nothing else. The server will not tell you which fields are different. I'd like to have a db server which would, but AFAIK they don't.
>To know what changed, you'd need to retrieve the current version of the record (into a separate cursor), then compare field by field with your current record etc etc, as described in that long paragraph with ouches and parentheses above. Life is tough.

The last thing you explained is what I thought of, I mean, the separate cursor and so on. That would led me to ask if there are events in CursorAdapters, not views, that could do that job done, just before saving my changes.

On the other hand I don't have a guide that let me develop using CursorAdapters instead of remote views. If anyone could help me with this last topic, that would be a big, big help.

Thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform