Skip to content

Definition blocks and NEXT

A linear query passes its result binding table to the next statement. NEXT keeps every column. NEXT YIELD keeps and optionally renames the listed columns.

RETURN 1 AS n, 2 AS m NEXT YIELD n AS kept RETURN kept * 3 AS value;

FILTER, MATCH, LET and RETURN in the continuation read those columns. RETURN * projects that incoming working table. An element reference stays attached to its graph, so the continuation can read its properties and labels or match through it. A null reference stays null. The current graph carries from one statement in the chain to the next. Semicolon-separated statements stay independent.

FOR n IN [1, 2]
RETURN n
NEXT FILTER n > 1
RETURN *;
MATCH (p:Person) RETURN p.name AS name NEXT FILTER name = 'Alice' RETURN name;

Mutation statements and catalog commands still do not form a NEXT chain. Procedure-body definitions remain syntax:

VALUE answer INTEGER = 42 RETURN answer NEXT YIELD answer AS n RETURN n;