Bird
0
0

What will be the result of executing the following function call?

medium📝 query result Q5 of 15
PostgreSQL - PL/pgSQL Fundamentals
What will be the result of executing the following function call?
CREATE FUNCTION square(x integer) RETURNS integer AS $$ BEGIN RETURN x * x; END; $$ LANGUAGE plpgsql; SELECT square(4);
A16
B8
CError: function not found
DNULL
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the function logic

    The function returns the square of the input integer by multiplying it by itself.
  2. Step 2: Calculate the output for input 4

    4 * 4 equals 16, so the function returns 16.
  3. Final Answer:

    16 -> Option A
  4. Quick Check:

    Function square(4) = 16 [OK]
Quick Trick: Multiplying input by itself returns square [OK]
Common Mistakes:
  • Confusing multiplication with addition
  • Expecting error due to missing semicolon after SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes