Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locking a Record
Message
From
09/09/2014 13:12:37
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
09/09/2014 12:53:19
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01607215
Message ID:
01607216
Views:
70
>I need to retrieve a record out of a queue, and I want to lock it to make sure that only one user retrieves and is working on a record at a time.
>
>I don't think this is a complicated concept, but I've never done it before. Can somebody give me a crash course on what I'm looking for? I'm going to have a status on the record of Pending/Done I think to explicitly mark that the record has been processed, but I need to work on the locking part. This is the requirement that was provided to me:
>
>This action must be safe across multiple webservers, meaning no 2 users could possibly receive the same row at the same time (atomic operation? Cross-database locking?)

Such pessimistic approaches are usually bad. What you can do instead is permit two people to get a record, and deny the save of the last one to click save.

Or the first person to start the record marks it pending with their userid. If they lose the connection, only they can re-access the record. Any record without an id is available to be received.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform