Bird
0
0

Identify the error in this PL/pgSQL code:

medium📝 Debug Q6 of 15
PostgreSQL - PL/pgSQL Fundamentals
Identify the error in this PL/pgSQL code:
DO $$
DECLARE
  val INT := 5;
BEGIN
  IF val > 3
    RAISE NOTICE 'Greater than 3';
  END IF;
END $$;
AMissing semicolon after RAISE NOTICE
BMissing THEN after IF condition
CIncorrect variable declaration
DEND IF should be ENDIF
Step-by-Step Solution
Solution:
  1. Step 1: Check IF syntax

    In PL/pgSQL, IF condition must be followed by THEN.
  2. Step 2: Analyze code

    The code misses THEN after IF val > 3, causing syntax error.
  3. Final Answer:

    Missing THEN after IF condition -> Option B
  4. Quick Check:

    IF requires THEN after condition [OK]
Quick Trick: Always put THEN after IF condition [OK]
Common Mistakes:
  • Forgetting THEN keyword
  • Confusing END IF with ENDIF
  • Assuming semicolon needed after RAISE NOTICE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes