Bird
0
0

Identify the error in this SQL transaction code:

medium📝 Debug Q6 of 15
SQL - Transactions and Data Integrity
Identify the error in this SQL transaction code:
BEGIN TRANSACTION
UPDATE products SET stock = stock - 1 WHERE id = 10
COMMIT;
ABEGIN TRANSACTION cannot be used with UPDATE
BCOMMIT must come before UPDATE
CMissing semicolons after statements
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check SQL statement syntax

    Each SQL statement should end with a semicolon to separate commands.
  2. Step 2: Identify missing semicolons

    Both BEGIN TRANSACTION and UPDATE lack semicolons, causing syntax errors.
  3. Final Answer:

    Missing semicolons after statements -> Option C
  4. Quick Check:

    SQL statements need semicolons to separate [OK]
Quick Trick: Always end SQL statements with semicolons [OK]
Common Mistakes:
  • Omitting semicolons between statements
  • Misordering COMMIT and UPDATE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes