final class FetchCursor
    implements ProgramStatement
    uses Snapshot
Public API: explicitly declared with @visibility public.

FETCH: reads the next row of an open cursor into local variables.

The optional words NEXT FROM and FROM carry no meaning and are not kept. The facts follow MYSQL-PROGRAM-CURSORS-001. Source: https://dev.mysql.com/doc/refman/8.4/en/fetch.html.

Reading the targets of a FETCHdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p(OUT a INT) BEGIN DECLARE c CURSOR FOR SELECT 1; FETCH NEXT FROM c INTO a; END');
    [$create->statement->body->statements[0]->targets[0]->value, $create->toString()] // => ['a', 'CREATE PROCEDURE p(OUT a INT) BEGIN DECLARE c CURSOR FOR SELECT 1; FETCH c INTO a; END']

Properties§

public non-empty-list<Name> $targets
public Name $cursor

Methods§

public function __construct(public Name $cursor, list<Name> $targets)

Parameters

$cursorNameThe cursor name
$targetslist<Name>The variables that receive the row; at least one
Calls 2
public function deriveProgram(Derivation $derivation, ProgramScope $scope): void

Checks that the cursor and the variables are declared.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 4

Test cases 6§

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

Dedicated tests 2
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Type declarations 1