apoc.cypher.runMany

Details

Syntax

apoc.cypher.runMany(statement, params [, config ]) :: (row, result)

Description

Runs each semicolon separated statement and returns a summary of the statement outcomes.

Input arguments

Name

Type

Description

statement

STRING

The Cypher statements to run, semicolon separated (;).

params

MAP

The parameters for the given Cypher statements.

config

MAP

{ statistics = true :: BOOLEAN }. The default is: {}.

Return arguments

Name

Type

Description

row

INTEGER

The row number of the run Cypher statement.

result

MAP

The result returned from the Cypher statement.

Usage Examples

This procedure is useful for executing multiple Cypher statements. We can create a node in one statement and create a relationship to itself in another statement, by running the following query:

CALL apoc.cypher.runMany(
  'CREATE (n:Node {name:$name});
   MATCH (n {name:$name})
   CREATE (n)-[:X {name:$name2}]->(n);',
  {name:"John", name2:"Doe"}
);
Results
row result

-1

{constraintsRemoved: 0, indexesRemoved: 0, nodesCreated: 1, rows: 0, propertiesSet: 1, labelsRemoved: 0, relationshipsDeleted: 0, constraintsAdded: 0, nodesDeleted: 0, indexesAdded: 0, labelsAdded: 1, relationshipsCreated: 0, time: 0}

-1

{constraintsRemoved: 0, indexesRemoved: 0, nodesCreated: 0, rows: 0, propertiesSet: 1, labelsRemoved: 0, relationshipsDeleted: 0, constraintsAdded: 0, nodesDeleted: 0, indexesAdded: 0, labelsAdded: 0, relationshipsCreated: 1, time: 0}

If we don’t want to see statistics for each Cypher statement, we can set statistics: false:

CALL apoc.cypher.runMany(
  'CREATE (n:Node {name:$name});
   MATCH (n {name:$name})
   CREATE (n)-[:X {name:$name2}]->(n);',
  {name:"John", name2:"Doe"},
  {statistics: false}
);
Results
row result