cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Code after apoc call not executing

y-pankaj
Node Link

Here's the code I want to run:

with x,y,sourceNode,targetNode,r
CALL apoc.do.case([
  x is not null and y is not null, 'CREATE (x)-[rels:ARC]->(y) SET rels = r',
  x is not null and y is null, 'CREATE (x)-[rels:ARC]->(targetNode) SET rels = r',
  x is null and y is not null, 'CREATE (sourceNode)-[rels:ARC]->(y) SET rels = r'
  ], '', {x:x, y:y, sourceNode:sourceNode, targetNode:targetNode, r:r}
) yield value 
with value
match (n:Entity { processed:1}), (m:Entity { processed:0})
where n.label = m.label
detach delete (m)

The following part of the code doesn't execute:

match (n:Entity { processed:1}), (m:Entity { processed:0})
where n.label = m.label
detach delete (m)

Running this also doesn't throw any error. Upon researching I found out that apoc.do.case must be followed by a return or an update statement. How do I get around this limitation and execute the above code in the exact order in a single query?

1 ACCEPTED SOLUTION

Hello @y-pankaj

I'am not an APOC expert yet, but I know Cypher almost by heart and I'm pretty sure that the reason why the last lines are not executing it's because either there is no rows in your WITH value clause or your MATCH match nothing.

You can write RETURN value after your yield to confirm at least first that there is rows returned by your CALL.

View solution in original post

2 REPLIES 2

Hello @y-pankaj

I'am not an APOC expert yet, but I know Cypher almost by heart and I'm pretty sure that the reason why the last lines are not executing it's because either there is no rows in your WITH value clause or your MATCH match nothing.

You can write RETURN value after your yield to confirm at least first that there is rows returned by your CALL.

Thanks for the reply @tard.gabriel. You were right! There were no rows in the WITH value clause. I modified the code to return the relationship r so that value is not empty. This solved the issue. Thanks again.