Atomicity demo (rollback): set a savepoint, move 50000 from project 1 to project 2 with two UPDATEs, then ROLLBACK TO the savepoint and SELECT to confirm BOTH budgets returned to their original values — the half-done transfer left no trace.
Atomicity demo (rollback): set a savepoint, move 50000 from project 1 to project 2 with two UPDATEs, then ROLLBACK TO the savepoint and SELECT to confirm BOTH budgets returned to their original values — the half-done transfer left no trace.
Answer
SAVEPOINT before_transfer; UPDATE projects SET budget = budget - 50000 WHERE project_id = 1; UPDATE projects SET budget = budget + 50000 WHERE project_id = 2; ROLLBACK TO SAVEPOINT before_transfer; SELECT project_id, name, budget FROM projects WHERE project_id IN (1, 2) ORDER BY project_id;