Materialize Documentation
s
Join the Community github/materialize

DECLARE

New in v0.5.3.

DECLARE creates a cursor, which can be used with FETCH, to retrieve a limited number of rows at a time from a larger query. Large queries or queries that don’t ever complete (TAIL) can be difficult to use with many PostgreSQL drivers that wait until all rows are returned before returning control to an application. Using DECLARE and FETCH allows you to fetch only some of the rows at a time.

Syntax

DECLARE cursor_name CURSOR WITHOUT HOLD FOR query
Field Use
cursor_name The name of the cursor to be created.
query The query (SELECT or TAIL) that will provide the rows to be returned by the cursor.