cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Problem with "WITH" clause in APOC.TRIGGER.ADD

I want to calculate the distance of the property-modified node from the specific labeled node ,and then set the distance as a property of the specific labeled node
So I use the clause WITH to transmmit the variety distance ,but the error appeared.
I took the screenshot as below:


who knows why this happened
I have transmmited the variety scope yet but it seems not work...

1 ACCEPTED SOLUTION

Hi @zhangjelly66

Your code.

with node,m
with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance
with m,distance

m is needed in the "with sqrt" line.

with node,m
with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance, m
with m,distance

I think it can be written in just one line.

with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance, m

View solution in original post

5 REPLIES 5

Hi @zhangjelly66

Your code.

with node,m
with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance
with m,distance

m is needed in the "with sqrt" line.

with node,m
with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance, m
with m,distance

I think it can be written in just one line.

with sqrt((m.x-node.x)^2+(m.y-node.y)^2) as distance, m

Thank you for the reply!
From your answer ,I undersood the usage of the WITH

//Line 5 to 8 can be replaced by
SET m.distance = sqrt((m.x-node.x)^2+(m.y-node.y)^2)

Thank you It's simpler and works~

Hi, bro, I have another question for help
Does the APOC.trigger could be modified?
Everytime I modify the trigger,I have to remove the existed apoc.trigger and add a new one...
It's little bored and troublesome to do this repeatable prosedure
Is there any way to modify the old one or by any other easier way to do that? It bothers me a lot recently...