#796

Reserve stock only if it's actually available

A user added an item to their cart — the backend needs to reserve three units in inventory, but only if there's actually enough stock. If you do «read stock → check → write» as separate statements, two parallel transactions can see the same number and both reserve the last unit. A single conditional update solves this atomically: try to increase reserved by three for the product with id 1, but only when qty - reserved is at least 3. If no row ends up updated — return «out of stock» to the user.

Just INSERT/UPDATE/DELETE — no trailing SELECT needed.

Your query result will appear here