apoc.cypher.runWriteProcedure
Syntax |
|
||
Description |
Alias for |
||
Input arguments |
Name |
Type |
Description |
|
|
The Cypher statement to run. |
|
|
|
The parameters for the given Cypher statement. |
|
Return arguments |
Name |
Type |
Description |
|
|
The result returned from the Cypher statement. |
|
|
This procedure cannot perform |
Using dynamic labels in Cypher
Node labels and relationship types can be referenced dynamically in Cypher without using APOC.
CREATE (n1:$(label))-[r:$(type)]->(n2:$(label))
MERGE (n1:$(label))-[r:$(type)]->(n2:$(label))
MATCH (n1:$(label))-[r:$(type)]->(n2:$(label))
The dynamically calculated type must evaluate to a STRING or LIST<STRING>.
For more information, see the Cypher Manual → CREATE,
MERGE, MATCH.
Example
Given this dataset:
CREATE (:Person {name: 'Alice', age: 30}),
(:Person {name: 'Bob', age: 25})
The following query dynamically constructs and executes a write statement, using parameters to pass values into the inner statement:
CALL apoc.cypher.runWrite(
'MATCH (p:Person {name: $name})
SET p.age = $newAge
RETURN p.name AS name, p.age AS age',
{name: 'Alice', newAge: 31}
)
YIELD value
RETURN value.name AS name, value.age AS age
| name | age |
|---|---|
"Alice" |
31 |
Each row returned by the inner statement is yielded as a value map, with the result columns as map keys.
apoc.cypher.runWrite is an alias for apoc.cypher.doIt.