Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Hello,
on MS-SQL Server you can use "Key Field & Timestamp"
which is IMHO the best conflict check method (no long SQL statement - very fast)
if you use other DB backends you can code a special CursorAdapter class that uses the same concept (isn't that much effort)
i don't have coded a field based conflict checking system yet since it's really much work for very little value, for me this scheme was ok (pseudocode)
IF !TABLEUPDATE(.t.,.f.,'someview')
MESSSAGEBOX('Another user has changed the record .. the record is now reloaded .. !')
TABLEREVERT('someview')
REFRESH('someview')
RETURN
ELSE
.. code to set form to non-editing status ..
ENDIF
a complete another approch would be to use a hand coded pessimistic locking scheme e.g.
user wants to edit a record:
-Rlock a special "editing table" which holds info which records are currently edited
-lockup key in "editing table", if not found add it .. else display user that the record is being changed by another user (it's also easy to display which user is working on the record - just add another field in the "editing table"), after that UNLOCK the "editing table" again so other users can use it ..(locking the "editing table" ensures the validity of the whole process, so no 2 users can get editing access to the same record)
-if lock was granted REQUERY the view so you have the latest data from the server for sure
-when user saves changes .. remove the entry from the "editing table"
with this scheme you don't ever have to handle conflicts cause they are excluded
drawbacks of this approach is that the locking table could be a bottleneck if the system has very much users
Regards
Christian
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement