Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-11-2021 12:41 AM
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, 😎 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
Solved! Go to Solution.
03-11-2021 08:16 AM
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',
{}
);
03-11-2021 06:42 AM
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',
{}
);
03-11-2021 06:56 AM
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.
03-11-2021 08:16 AM
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',
{}
);
All the sessions of the conference are now available online