My command lookslike this:
MATCH (c:Client)
WITH collect(c) AS clients
CALL apoc.cypher.mapParallel2('
CALL apoc.do.case([
_.type="Plain", "SET _.state=1",
_.type="Super", "SET _.state=2"
],"SET _.state=0",
{})
YIELD value
RETURN value',
{}, clients, 8) YIELD value
RETURN value.client.login as login, value.client.state as state
And I am getting:
Failed to invoke procedure `apoc.cypher.mapParallel2`: Caused by: org.neo4j.graphdb.NotInTransactionException: This transaction has already been closed.
Also, how should I escape quotes in case state
is STRING
If you want to update properties I would rather use apoc.periodic.iterate
, as shown below:
CALL apoc.periodic.iterate(
"match (c:Client) return c",
'CALL apoc.do.case([
c.type="Plain", "SET c.state=5",
c.type="Super", "SET c.state=6"
],"SET c.state=0",
{c: c})
YIELD value
RETURN value',
{}
);
Thanks, I have done the same in the meantime. Now I hit another problem:
What if the state
is String? How should I escape the quotes?
Please note that my apoc.do.case
is a monster in the real use case, lots of sets as a result of complex calculation.
CALL apoc.periodic.iterate(
"match (c:Client) return c",
'CALL apoc.do.case([
c.type="Plain", "SET c.state=\'foo\'",
c.type="Super", "SET c.state=\'bar\'"
],"SET c.state=\'baz\'",
{c: c})
YIELD value
RETURN value',
{}
);