Bird
0
0

Identify the error in this block:

medium📝 Debug Q6 of 15
PostgreSQL - Advanced PL/pgSQL
Identify the error in this block:
DO $$
BEGIN
  RAISE EXCEPTION 'Error!';
EXCEPTION
  WHEN division_by_zero THEN
    RAISE NOTICE 'Handled division by zero';
END $$;
ARAISE EXCEPTION syntax is incorrect
BMissing END statement
CException type does not match raised error
DEXCEPTION block must be empty
Step-by-Step Solution
Solution:
  1. Step 1: Check raised exception type

    The block raises a generic exception with message 'Error!'.
  2. Step 2: Check exception handler

    The handler only catches division_by_zero, which does not match the raised exception.
  3. Final Answer:

    Exception type does not match raised error -> Option C
  4. Quick Check:

    Exception mismatch error = C [OK]
Quick Trick: Exception handler must match raised error type [OK]
Common Mistakes:
  • Assuming all exceptions are caught by any handler
  • Forgetting to add WHEN OTHERS for generic catch
  • Thinking syntax error due to RAISE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes