-2

In given cypher query it showing error. Please let me know what is wrong in below Cypher query:

MATCH (pcp:PCP)-[]->(mt:MONEYTRANSFER{MTCN:'1618087665684829'}) return 
CASE WHEN  EXISTS( (pcp)-[:SENT_BY]-(mt{MTCN:'1618087665684829'}) ) 
THEN null ELSE MERGE (pcp:PCP)-[]->(mt:MONEYTRANSFER{MTCN:'1618087665684829'})
END
Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
Saurabh wagh
  • 61
  • 1
  • 9

1 Answers1

0

try going through this question on stackoverflow. It gives the example of using CASES with MERGE

there's a work around for your query:

MATCH (pcp:PCP)-[r]->(mt:MONEYTRANSFER{MTCN:'1618087665684829'})
WITH pcp,r,mt, CASE WHEN (type(r) = 'SENT_BY') THEN [] ELSE ['create'] 
END as array1
FOREACH (el1 in array1 | CREATE (pcp)-[:SENT_BY]->(mt))
return pcp,mt,r

Edit: You cannot create a realtionship without specifying the label/type for it.

Hope this helps!

techie95
  • 515
  • 3
  • 16