Bird
0
0

Which of the following is the correct way to declare a variable of a composite type person in a PL/pgSQL function?

easy📝 Syntax Q3 of 15
PostgreSQL - Advanced Features
Which of the following is the correct way to declare a variable of a composite type person in a PL/pgSQL function?
ADECLARE p TYPE person;
BDECLARE p AS person;
CDECLARE p person;
DDECLARE p RECORD person;
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable declaration in PL/pgSQL

    Variables are declared with DECLARE name type; without AS or TYPE keywords.
  2. Step 2: Identify correct syntax

    DECLARE p person; matches the correct syntax for composite type variable declaration.
  3. Final Answer:

    DECLARE p person; -> Option C
  4. Quick Check:

    Variable declaration = DECLARE name type; [OK]
Quick Trick: Declare composite variables like normal types without extra keywords [OK]
Common Mistakes:
  • Adding AS or TYPE keywords incorrectly
  • Using RECORD with a type name
  • Confusing syntax with other languages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes