user2645105
user2645105

Reputation: 11

To delete nodes and its relations

I'm using following query to delete all the nodes and relations:

START a=node(2) 
MATCH (a)-[r:PUBLISHED_BY]->(c), 
(b)-[s:PUBLISHED_UNDER]->(c) 
DELETE r,s,c;

but I'm getting the following error message.

==> TransactionFailureException: Unable to commit transaction

Please help me where I'm doing wrong.

Upvotes: 0

Views: 160

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33175

You have to delete all relationships when you delete nodes. Try this one.

MATCH (a)-[:PUBLISHED_BY]->(c)
WHERE id(a) = 2
OPTIONAL MATCH (c)-[r]-()
DELETE c, r;

Upvotes: 4

Related Questions