L3 Q6
Advanced Level
Practice Question
Level 3 - Question 6: Transaction Management with COMMIT and ROLLBACK
Scenario
You need to transfer $500 from Account A to Account B. This involves two operations: deducting from Account A and adding to Account B. Both must succeed or both must fail to maintain data integrity.
Task
Write a transaction that updates both accounts. Use COMMIT if both operations succeed, or ROLLBACK if there's an error.
Sample Schema: accounts
| account_id | account_holder | balance |
|---|---|---|
| A001 | John Doe | 2000.00 |
| A002 | Jane Smith | 1500.00 |