Cypher Neo4J - CASE Expression with MERGE

后端 未结 4 1207
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 11:25

I\'m trying to implement the logic in Cypher where, based on a particular condition (CASE Statement), I would create some nodes and relationships; the code is

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 12:13

    Fixed the issue as below

    WITH u, b2,b1, g, r1, CASE  WHEN (b1.fork='y' and b2.fork='success') or (b1.fork='n') or   (b1.fork='success') THEN ['ok'] ELSE [] END as array1
    FOREACH (el1 in array1 | MERGE (u)-[r2:STAGE {startdate:20141225, enddate:99999999, status:'InProgress'}]->(b2))
    

    i.e. used CASE WHEN to create a dummy array that in a way has dummy elements matching the count of matches and then use FOREACH to iterate through the result.

    Again, thanks Stefan for the idea...

    Deepesh

提交回复
热议问题