Bird
0
0

Consider the following PL/pgSQL block:

medium📝 query result Q13 of 15
PostgreSQL - PL/pgSQL Fundamentals
Consider the following PL/pgSQL block:
DECLARE
  total integer := 5;
BEGIN
  total := total + 3;
  RAISE NOTICE '%', total;
END;

What will be the output when this block runs?
A8
B5
C3
DError: variable not initialized
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial value assignment

    The variable total is declared and initialized to 5.
  2. Step 2: Calculate the new value after addition

    The statement total := total + 3; adds 3 to 5, resulting in 8.
  3. Final Answer:

    8 -> Option A
  4. Quick Check:

    5 + 3 = 8 [OK]
Quick Trick: Add assigned values step-by-step to find final result [OK]
Common Mistakes:
  • Ignoring initial value and assuming zero
  • Confusing assignment operator with equality
  • Expecting error due to missing BEGIN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes