Handle lost update (pattern)
SQL
Easy
2 views
Problem Description
Two sessions update same row. Show a safe pattern using a version column and conditional update.
Sample Test Case
Input:
Items(id, qty, version)
Constraints
Use optimistic locking
Official Solution
UPDATE Items SET qty = qty - 1, version = version + 1 WHERE id = 10 AND version = 5;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!