Bird
0
0

Given the function below, what will be the output of SELECT add_one(5);?

medium📝 query result Q13 of 15
PostgreSQL - PL/pgSQL Fundamentals
Given the function below, what will be the output of SELECT add_one(5);?
CREATE FUNCTION add_one(x integer) RETURNS integer AS $$ BEGIN RETURN x + 1; END; $$ LANGUAGE plpgsql;
A6
BSyntax error
C5
DNULL
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function logic

    The function takes an integer input x and returns x + 1.
  2. Step 2: Apply the input value 5

    Calling add_one(5) returns 5 + 1 = 6.
  3. Final Answer:

    6 -> Option A
  4. Quick Check:

    Input 5 plus 1 equals 6 [OK]
Quick Trick: Function adds 1 to input, so 5 becomes 6 [OK]
Common Mistakes:
  • Confusing input and output values
  • Expecting syntax error due to unfamiliarity
  • Assuming function returns NULL without reason

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes