Bird
0
0

Consider this code:

medium📝 query result Q5 of 15
PostgreSQL - Advanced PL/pgSQL
Consider this code:
DECLARE cur CURSOR FOR SELECT name FROM employees;
OPEN cur;
FETCH ALL FROM cur;

What will the FETCH ALL command do?
ARetrieve only the first row
BRetrieve all rows from the cursor at once
CRetrieve no rows until FETCH NEXT is called
DCause a syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand FETCH ALL

    FETCH ALL returns all remaining rows from the cursor in one go.
  2. Step 2: Apply to given code

    Since cursor is opened, FETCH ALL retrieves all rows from employees table.
  3. Final Answer:

    Retrieve all rows from the cursor at once -> Option B
  4. Quick Check:

    FETCH ALL = fetch all remaining rows [OK]
Quick Trick: FETCH ALL gets all rows remaining in cursor [OK]
Common Mistakes:
  • Thinking FETCH ALL fetches one row
  • Assuming FETCH ALL causes error
  • Confusing FETCH ALL with FETCH NEXT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes