Bird
0
0

Find the error in this DO block:

medium📝 Debug Q7 of 15
PostgreSQL - PL/pgSQL Fundamentals
Find the error in this DO block:
DO $$
DECLARE
  msg TEXT;
BEGIN
  msg := 'Hello';
  RAISE NOTICE msg;
END
$$;
AMissing semicolon after RAISE NOTICE
BVariable msg not declared
CRAISE NOTICE requires a format string with % placeholders
DDO blocks cannot use RAISE NOTICE
Step-by-Step Solution
Solution:
  1. Step 1: Check RAISE NOTICE syntax

    RAISE NOTICE expects a format string with % placeholders for variables.
  2. Step 2: Identify missing format string

    Here, msg is passed directly without format string, causing error.
  3. Final Answer:

    RAISE NOTICE requires a format string with % placeholders -> Option C
  4. Quick Check:

    RAISE NOTICE syntax = format string needed [OK]
Quick Trick: Use RAISE NOTICE 'text %', var; format [OK]
Common Mistakes:
  • Passing variable directly without format string
  • Assuming RAISE NOTICE prints variables automatically
  • Ignoring semicolon placement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes