Information générale
Catégorie:
Codage, syntaxe et commandes
>If the lock column is called lock_user and it will accept NULLs than use a SQL UPDATE that looks something like this:
>
>UPDATE table
> SET lock_user = id
> WHERE pk_column = pk_value
> AND lock_user IS NULL
>
>Only one person will be able to hit the row (or page depending on the database).
>
>Then check the effected-row count or check the lock_user column to see if you got the lock.
>
>-Mike
This is exactly what I do. I put it in a stored procedure on the backend (for performance), but there's no reason why you can't use a VFP Procedure. Your backend server should resolve any conflict between two users trying to UPDATE at the same time.
I would also modify the UPDATE a bit:
UPDATE table
SET lock_user = id
WHERE pk_column = pk_value
AND lock_user IS NULL OR lockuser = id
HTH
Précédent
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