Bird
0
0

You wrote this AFTER UPDATE trigger:

medium📝 Debug Q14 of 15
SQL - Triggers
You wrote this AFTER UPDATE trigger:
CREATE TRIGGER trg AFTER UPDATE ON employees
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE id = NEW.id;
END;

What problem will occur when you update an employee's salary?
ASalary will not change
BTrigger will not run at all
CSyntax error prevents trigger creation
DInfinite loop causing stack overflow
Step-by-Step Solution
Solution:
  1. Step 1: Analyze trigger logic

    The trigger updates the same table it is triggered on, causing the trigger to fire again.
  2. Step 2: Identify the effect of recursive updates

    This causes an infinite loop of updates, eventually causing stack overflow or error.
  3. Final Answer:

    Infinite loop causing stack overflow -> Option D
  4. Quick Check:

    Trigger updating same table without stop = infinite loop [OK]
Quick Trick: Avoid triggers updating same table without condition to stop recursion [OK]
Common Mistakes:
  • Not realizing trigger recursion
  • Expecting trigger to run once only
  • Ignoring NEW and OLD references

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes