General information
Category:
Coding, syntax & commands
>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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only