I've been using the WITH clause to decalre variables for later use such as...
WITH 'inherits from>' AS caption
MATCH (bv:Vertex {name:'«Root»'})
MATCH (iv:Vertex {name:'Datastore'})
MATCH (abv:ArcBase {name:'INHERITANCE'})
MERGE (iv)-[ibi:INHERITANCE {name:iv.name+'-'+abv.name+'->'+bv.name}]->(bv)
ON CREATE
SET ibi.caption=caption,
ibi.originName=iv.name, ibi.originUUID=iv.uuid,
ibi.destinationName=bv.name, ibi.destinationUUID=bv.uuid
ON MATCH
SET ibi.caption=caption,
ibi.originName=iv.name, ibi.originUUID=iv.uuid,
ibi.destinationName=bv.name, ibi.destinationUUID=bv.uuid
;
Is this an appropriate use of the clause? If so, why does the above version work, but
MATCH (bv:Vertex {name:'«Root»'})
MATCH (iv:Vertex {name:'Datastore'})
MATCH (abv:ArcBase {name:'INHERITANCE'})
WITH 'inherits from>' AS caption
MERGE (iv)-[ibi:INHERITANCE {name:iv.name+'-'+abv.name+'->'+bv.name}]->(bv)
ON CREATE
SET ibi.caption=caption,
ibi.originName=iv.name, ibi.originUUID=iv.uuid,
ibi.destinationName=bv.name, ibi.destinationUUID=bv.uuid
ON MATCH
SET ibi.caption=caption,
ibi.originName=iv.name, ibi.originUUID=iv.uuid,
ibi.destinationName=bv.name, ibi.destinationUUID=bv.uuid
;
i.e. moving the WITH clause to below the matches cause the subsequent MERGE to fail?
TIA,
Paolo