Skip to content

CALL procedure clause

Marijn van Wezel edited this page Dec 13, 2022 · 8 revisions

The CALL procedure clause is used to call a procedure deployed in the database. It accepts a procedure to call and a list of variables to yield.

Query::callProcedure(Procedure|string $procedure, AnyType|bool|float|int|array|Pattern|string|(AnyType|bool|float|int|array|Pattern|string)[] $yields = []): Query

Parameters

  • $procedure : The procedure to call.
  • $yields : The result fields that should be returned.

Relevant methods

  • setProcedure(Procedure $procedure): self : Sets the procedure to call. This overwrites any previously set procedure.
  • addYield(Alias|string|Variable $yields): self : Adds one or more variables to yield.

Examples

Call a procedure using CALL

$statement = query()
    ->callProcedure("apoc.json")
    ->build();

$this->assertSame("CALL `apoc.json`()", $statement);

Call a procedure using CALL YIELD

$statement = query()
    ->callProcedure("dbms.procedures", [
        variable('name'),
        variable('signature'),
    ])
    ->build();

$this->assertSame("CALL `dbms.procedures`() YIELD name, signature", $statement);

Call a procedure with literal arguments

$procedure = Procedure::raw("dbms.security.createUser", ['example_username', 'example_password', false]);
$statement = query()
    ->callProcedure($procedure)
    ->build();

$this->assertSame("CALL `dbms.security.createUser`('example_username', 'example_password', false)", $statement);

External links