final class CursorDeclaration
    implements Declaration
    uses Snapshot
Public API: explicitly declared with @visibility public.

DECLARE ... CURSOR FOR: a named cursor over the rows of a query.

The query is derived where the cursor is declared, with the variables declared before it in scope (MYSQL-PROGRAM-BLOCK-001). Source: https://dev.mysql.com/doc/refman/8.4/en/declare-cursor.html.

Reading a cursor declarationdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p() BEGIN DECLARE c CURSOR FOR SELECT a FROM t; END');
    $create->statement->body->declarations[0]->name->value // => 'c'

Properties§

public Name $name
public Query $query

Methods§

public function __construct(public Name $name, public Query $query)

Parameters

$nameNameThe cursor name
$queryQueryThe query whose rows the cursor reads
public function render(Output $out): void

Writes the declaration.

Parameters

$outOutput
Calls 2

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 checks 1