Bird
0
0

What will happen when running this DO block?

medium📝 query result Q5 of 15
PostgreSQL - PL/pgSQL Fundamentals
What will happen when running this DO block?
DO $$
DECLARE
  x INTEGER := 10;
BEGIN
  x := x + 5;
  RAISE NOTICE 'Value: %', x;
END
$$;
AERROR: variable x not declared
BNOTICE: Value: 15
CNOTICE: Value: 10
DNo output, variable changes silently
Step-by-Step Solution
Solution:
  1. Step 1: Check variable declaration and initialization

    Variable x is declared as INTEGER and initialized to 10.
  2. Step 2: Analyze the increment and RAISE NOTICE

    x is increased by 5, so x becomes 15, then printed.
  3. Final Answer:

    NOTICE: Value: 15 -> Option B
  4. Quick Check:

    Variable update and notice = 15 [OK]
Quick Trick: Declare variables in DECLARE block before BEGIN [OK]
Common Mistakes:
  • Forgetting DECLARE section
  • Expecting original value without increment
  • Assuming no output from RAISE NOTICE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes