The error does not undo the first write
BEGIN, COMMIT, ROLLBACK (desktop) · level 5 of 6
Opening your saved work…
Sign in to save across devices → · Download your guest work before switching accounts.
The error does not undo the first write · BEGIN, COMMIT, ROLLBACK (desktop) · level 5 of 6
The error does not undo the first write
A 70-dollar transfer from guest 2 to guest 3 failed halfway. Guest 3 is 70 richer. Guest 2 is unchanged.
Run this on a fresh copy in the desktop shell, one statement at a time; the second UPDATE is refused by the balance CHECK. Write down both balances and the exact error, then fix the handling: the right next statement is the one that leaves both balances exactly as they were. Do not replace ROLLBACK with COMMIT.
This one runs in desktop SQLite 3.25 or newer, not in the browser. Download the kit
The query that runs and lies
SELECT id, balance FROM guests WHERE id IN (2, 3) ORDER BY id;
BEGIN;
UPDATE guests SET balance = balance + 70 WHERE id = 3;
UPDATE guests SET balance = balance - 70 WHERE id = 2;
-- the second update is refused; the first is pending- ReviewBoth or neither, paragraph 2
- Opens after the hint or a second check.
Practice here is evidence for you and your instructor, never a grade. Grades live in Canvas.