Bird
0
0

You wrote a row-level trigger but it fires only once per statement. What is the likely cause?

medium📝 Debug Q6 of 15
PostgreSQL - Triggers in PostgreSQL
You wrote a row-level trigger but it fires only once per statement. What is the likely cause?
ATrigger was created with FOR EACH STATEMENT instead of FOR EACH ROW.
BTrigger function is missing RETURN statement.
CTrigger is defined on the wrong table.
DTrigger timing is AFTER instead of BEFORE.
Step-by-Step Solution
Solution:
  1. Step 1: Identify trigger firing frequency

    Row-level triggers must be created with FOR EACH ROW to fire per row.
  2. Step 2: Check trigger creation syntax

    If FOR EACH STATEMENT is used, trigger fires once per statement, not per row.
  3. Final Answer:

    Trigger was created with FOR EACH STATEMENT instead of FOR EACH ROW. -> Option A
  4. Quick Check:

    FOR EACH ROW required for row-level triggers [OK]
Quick Trick: FOR EACH ROW needed for row-level triggers [OK]
Common Mistakes:
  • Confusing FOR EACH ROW and FOR EACH STATEMENT
  • Ignoring missing RETURN in trigger function
  • Assuming timing affects firing count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes