Skip to content
C

Correct a Mistake with a Savepoint

Mediumsql
Learn the Concept: SAVEPOINT

Write a transaction that: debits account 1 by 200, sets a savepoint named sp1, mistakenly credits account 2 by 9999, rolls back to sp1 to undo that mistake, then correctly credits account 2 by 200, and commits.

sql
CREATE TABLE accounts ( id INTEGER PRIMARY KEY, balance INTEGER NOT NULL ) ENGINE=InnoDB;

Sample data:

sql
INSERT INTO accounts (id, balance) VALUES (1, 1000), (2, 500);

Related Problems

Input (stdin)

Output

Run your code to see output here...