I'm using neo4j 2.1.4 community edition. I have created a some nodes and relationships as below.
Now i wanted acheive the below tasks:
I have a node(purple color node) with the properties like ID, Name, Created_Date and End_Date. and it has the relationship property as flag:ACTIVE
1) I wanted to add a node below the Orange color node and above yellow color node i.e., the newly created node will be like a parallel node of purple node with HAS
relationship between the orange and yellow color node with a relationship property Status:ACTIVE
.
3) Also the existing purple color node relationship property Status:'ACTIVE'
should change to INACTIVE
and the END_Date of the purple colour node should become the newly created node's Created_Date
.
These all things i wanted to acheive in a single query.
I have written the below query to acheive this. I'm able to create a new node with created_date but not able to craete a relationship. I'm not sure where it's going wrong.
Query:
MERGE (og:OperatingGroup {OperatingGroup_ID:'NOP',OpeartingGroup_Name:'Operating'})
ON CREATE SET og.GOG_Start_Date= timestamp()
WITH og
MATCH (h:Hierarchy {Hierarchy_ID:181,Hierarchy_Name:'Global Property Hierarchy'})
Create (h)-[:HAS]->(og)
return h,og;
Things which are not achieved in the above query is:
1)creating relationship with property
2)Updating the END_Date in the old node(purple node)
3)Updating the old node's relationship property to INACTIVE
So how to acheie all thse things in a single cypher query?
Thanks