Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBC in pessimistic mode
Message
From
04/11/1997 07:55:13
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00057793
Message ID:
00058119
Views:
30
>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
Map
View

Click here to load this message in the networking platform