final class DeclareCursor
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

DECLARE: a cursor over the rows of a query.

Mirrors PostgreSQL's DeclareCursorStmt (portalname, options, query). The facts follow PG-CURSOR-001. Source: https://www.postgresql.org/docs/17/sql-declare.html. Status: Implemented.

Reading a cursor declarationdoctest
$declare = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('DECLARE c SCROLL CURSOR WITHOUT HOLD FOR SELECT 1');
    [$declare->statement->name->value, $declare->toString()] // => ['c', 'DECLARE c SCROLL CURSOR WITHOUT HOLD FOR SELECT 1']

Properties§

public list<CursorOption> $options
public Name $name
public Holdability|null $hold
public Query $query

Methods§

public function __construct(
    public Name $name,
    list<CursorOption> $options,
    public Holdability|null $hold,
    public Query $query,
)

Parameters

$nameNameThe cursor name
$optionslist<CursorOption>The options in written order
$holdHoldability|nullWITH HOLD or WITHOUT HOLD, when written
$queryQueryThe query: a query statement

Throws

InvalidConstruction When the query is not a query statement, or an option is not a cursor option
Calls 5
public function deriveStatement(Derivation $derivation): void

Derives the query and checks the options.

Parameters

$derivationDerivation
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Type declarations 2