classDeclareCursor
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.
$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> $optionspublic Name $namepublic Holdability|null $holdpublic Query $queryMethods§
public function __construct(
public Name $name,
list<CursorOption> $options,
public Holdability|null $hold,
public Query $query,
)Parameters
$name | Name | The cursor name |
$options | list<CursorOption> | The options in written order |
$hold | Holdability|null | WITH HOLD or WITHOUT HOLD, when written |
$query | Query | The query: a query statement |
Throws
InvalidConstruction When the query is not a query statement, or an option is not a cursor optionCalls 5
- static-call Check::listOf() line 50
- class-const CursorOption::class() line 50
- static-call Check::input() line 51
- method-call Sources::statement() line 51
- new Sources line 51
public function deriveStatement(Derivation $derivation): voidDerives the query and checks the options.
Parameters
$derivation | Derivation |
Calls 2
- method-call CursorFacts::declare() line 59
- new CursorFacts line 59
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 67
- class-const NameUse::Column() line 67
- function-call
explodeline 69
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
DeclareCursorTestcalls