0
votes

I tried to run below cypher query in Neo4j(3 Merge Statement in once)

MERGE (paymentinstrument{SENDER_CREDITCARD:'123444'})-[rPAYMENTINSTRUMENT:PROFILECHANGE_PI{}]->( profilechange )                     
    ON CREATE SET rPAYMENTINSTRUMENT.CREATETIMESTAMP = toInt('1413911269726') 
    ON MATCH SET rPAYMENTINSTRUMENT.UPDATETIMESTAMP = toInt('1413911269726') 
MERGE (profilechange{PROFILECHANGEIDENTIFIER:'ABCD'})-[rPROFILECHANGEDEVICE:HAS_DEVICE{}]->( device )                                
    ON CREATE SET rPROFILECHANGEDEVICE.CREATETIMESTAMP = toInt('1413911269726')                                                         
    ON MATCH SET rPROFILECHANGEDEVICE.UPDATETIMESTAMP = toInt('1413911269726') 
MERGE (profilechange{PROFILECHANGEIDENTIFIER:'ABCD'})-[rPROFILECHANGEIPADDRESS:HAS_IP{}]->( ipaddress )
    ON CREATE SET rPROFILECHANGEIPADDRESS.CREATETIMESTAMP = toInt('1413911269726') 
    ON MATCH SET rPROFILECHANGEIPADDRESS.UPDATETIMESTAMP = toInt('1413911269726')

which encountered below error

Can't create node profilechange with labels or properties here. The variable is already declared in this context

Does anyone have idea or workaround for this issue ?Thanks

1

1 Answers

1
votes

You have two merges starting with MERGE (profilechange{PROFILECHANGEIDENTIFIER:'ABCD'}) so, its like you are defining two references with the same name

second use, should be

 MERGE (profilechange)--

Also, you syntax is bad in the error prone sense.

In "Learning Neo4j", the author :) advises this syntax

 (reference:Label{key:'value'})-[r2:RELATIONNAME]->(reference2:Label{you:'got it'})