Bird
0
0

Given this function:

medium📝 query result Q5 of 15
PostgreSQL - Advanced PL/pgSQL
Given this function:
CREATE FUNCTION get_info(OUT id INT, OUT name TEXT) AS $$ BEGIN id := 1; name := 'Alice'; END; $$ LANGUAGE plpgsql;
SELECT * FROM get_info();

What will the query return?
A1 | Alice
Bid | 1, name | Alice
CError: function must return a value
DEmpty result set
Step-by-Step Solution
Solution:
  1. Step 1: Recognize multiple OUT parameters

    The function returns a record with columns 'id' and 'name' set inside the function.
  2. Step 2: Understand SELECT * output

    SELECT * returns a row with column names and their assigned values.
  3. Final Answer:

    id | 1, name | Alice -> Option B
  4. Quick Check:

    Multiple OUT parameters return named columns [OK]
Quick Trick: Multiple OUT parameters return a record with named columns [OK]
Common Mistakes:
  • Expecting unnamed values
  • Thinking explicit RETURN is required
  • Assuming error due to no RETURNS clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes