Hello,
I am trying to use merge on create clause combine with an apoc procedure as I can't use parameters on on node labels. My query is shown bellow:
req = """
MERGE (a {key:$sHash})
ON CREATE
SET a.uri = $s
WITH a as subject
call apoc.create.addLabels(subject, [$typeSub]) YIELD node as sub
ON MATCH
SET a.uri = $s
WITH a as subject
call apoc.create.addLabels(subject, [$typeSub]) YIELD node as sub
MERGE (ob {key:$oHash})
ON CREATE
SET ob.uri = $obj
WITH collect(ob) as object
call apoc.create.addLabels(object, [$typeObj]) YIELD node as ob
MERGE (sub)-[r:IRI {key:$sHash+$oHash+$pHash}]->(ob)
ON CREATE
SET r.uri = $pred
WITH r as rel
call apoc.refactor.setType(rel, $pred) YIELD output
RETURN output
"""
res = neo4j.run(req, parameters={"s":s, 'typeSub':typeSub, 'typeObj':typeObj, "sHash":sHash, "obj":obj, "oHash":oHash, 'pred':pred, 'pHash':pHash}).data()
But i got an error:
ClientError: [Statement.SyntaxError] Invalid input 'N': expected 'p/P' (line 7, column 14 (offset: 215))
" ON MATCH"
^
I am asking my self if can include apoc procedure in merge on create clause. If yes how I can correct my query, If not what's the alternative that I can use.
Thanks