Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-17-2020 03:17 PM
Hello,
I have created an excel-sheet that uses the excel-functions to write the necessary code to implement the relations of the excel-sheet to Neo4J with Cypher code. To do that I write the code in an extra row and copy-paste it into Neo4J. This works perfectly with the nodes.
Example:
Create (a2: Organisation { Dach_Organisation: 'xxxxxx', ORGA_ID: '926785240' })
Create (a3: Organisation { Dach_Organisation: 'xxxxxx', ORGA_ID: '1453453434' })
I can copy all the creation requests in Neo4J at once and it works.
My problem starts with the code to create the relations.
MATCH (a: Organisation), (b:Projekt)
WHERE a.ORGA_ID= '926785240' AND b.PROJEKT_ID= '207481'
MERGE (a) - [r: Arbeit { Foerdersumme_in_EUR:' ' ,TIE_BY_ATTRIBUTE_1: '' ,TIE_BY_ATTRIBUTE_2: '' } ] -> (b)
MATCH (a: Organisation), (b:Projekt)
WHERE a.ORGA_ID= '' AND b.PROJEKT_ID= '03F0622A_BMBF'
MERGE (a) - [r: Arbeit { Foerdersumme_in_EUR:' xxxx' ,TIE_BY_ATTRIBUTE_1: '' ,TIE_BY_ATTRIBUTE_2: '' } ] -> (b)
If I just use it one time it works but if I try two or more of this at the same time I get the following error:
WITH is required between MERGE and MATCH (line 4, column 1 (offset: 202))
"MATCH (a: Organisation), (b:Projekt)"
^
Is there a way to prevent that error? I would like to copy and past a lot of this requests and do them at once.
Thank You!
12-17-2020 04:36 PM
I think you need semi-colons between the merge statements. I think the problem is that since you've inadvertently made it one big block, Cypher is trying to reuse the variable a
(which would be bad.)
MATCH (a: Organisation), (b:Projekt)
WHERE a.ORGA_ID= '926785240' AND b.PROJEKT_ID= '207481'
MERGE (a) - [r: Arbeit { Foerdersumme_in_EUR:' ' ,TIE_BY_ATTRIBUTE_1: '' ,TIE_BY_ATTRIBUTE_2: '' } ] -> (b)
; // I think you need this semi colon
MATCH (a: Organisation), (b:Projekt)
WHERE a.ORGA_ID= '' AND b.PROJEKT_ID= '03F0622A_BMBF'
MERGE (a) - [r: Arbeit { Foerdersumme_in_EUR:' xxxx' ,TIE_BY_ATTRIBUTE_1: '' ,TIE_BY_ATTRIBUTE_2: '' } ] -> (b)
12-17-2020 08:08 PM
I agree with @clem! You just need to add the semicolon and run in Cypher-shell or enable multi-statement query editor (as a screenshot) in the neo4j browser. Hope this helps
All the sessions of the conference are now available online