This page covers how to invoke a stored procedure with CALL and feed its results into the rest of a query.
The YIELD clause names the columns produced by a procedure, and optionally renames them. Using a greet(name: STRING) RETURNS (greeting: STRING) procedure:
GQLCALL greet('World') YIELD greeting -- Rename a yielded column with AS CALL greet('World') YIELD greeting AS msg
Without YIELD, all output columns are returned. For VOID procedures, there is no output:
GQL-- Returns the greeting column CALL greet('World') -- VOID procedure, no output CALL log_event('System started')
Results from YIELD can flow into subsequent query clauses. Using a count_all_nodes() RETURNS (cnt: INTEGER) procedure:
GQLCALL count_all_nodes() YIELD cnt MATCH (n:Person) WHERE n.age > cnt * 3 RETURN n
The yielded columns replace the outer binding row — variables from earlier clauses are not visible after a named CALL ... YIELD. To carry variables through, project them in a RETURN before the CALL, or use the inline CALL { ... } form with explicit variable import (see CALL).
Prefix CALL with OPTIONAL to suppress the "procedure not found" error when the named procedure does not exist. Compare:
GQL-- Errors with: procedure 'maybe_proc' not found CALL maybe_proc() YIELD result RETURN result
GQL-- No error; returns an empty result with column `result` OPTIONAL CALL maybe_proc() YIELD result RETURN result
This is the lookup-failure path only. If a named procedure resolves and runs successfully but yields zero rows, the result is still an empty table — OPTIONAL does not insert a NULL-padded row in that case. Rich NULL-padding semantics (preserve outer rows when the subquery is empty) apply only to the inline subquery form OPTIONAL CALL { ... } documented in CALL.