Bird
0
0

You wrote this code inside a PostgreSQL function:

medium📝 Debug Q14 of 15
PostgreSQL - PL/pgSQL Fundamentals
You wrote this code inside a PostgreSQL function:
RAISE EXCEPTION 'Error: %', message;

But it causes an error: "ERROR: column "message" does not exist". What is the likely problem?
AThe variable 'message' is not declared or out of scope.
BRAISE EXCEPTION cannot use placeholders like '%'.
CYou must use RAISE WARNING instead of EXCEPTION for variables.
DThe syntax requires double quotes around 'message'.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the error message

    The error says column "message" does not exist, meaning 'message' is treated as a column or variable but is undefined.
  2. Step 2: Check variable declaration and scope

    In PL/pgSQL, variables must be declared before use. If 'message' is not declared or out of scope, this error occurs.
  3. Final Answer:

    The variable 'message' is not declared or out of scope. -> Option A
  4. Quick Check:

    Undefined variable causes this error [OK]
Quick Trick: Declare variables before using in RAISE [OK]
Common Mistakes:
  • Thinking placeholders '%' are invalid
  • Using RAISE WARNING instead of EXCEPTION for variables
  • Adding quotes around variable names incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes