statement
DECLARE CURSOR
Declares a PostgreSQL server-side cursor and opens it for fetching. Ordinary cursors require a transaction. Example target: PostgreSQL 17. Use only the isolated starter dataset; setup and expected results are in the batch evidence.
Formal Syntax & Structure
sql syntaxsql
DECLARE name CURSOR FOR queryWorking Example
Example Snippetsql
BEGIN;DECLARE lab_cursor CURSOR FOR SELECT id FROM customers ORDER BY id;