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 :tired_face:
I have transmmited the variety scope yet but it seems not work...

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
2 Likes
//Line 5 to 8 can be replaced by
SET m.distance = sqrt((m.x-node.x)^2+(m.y-node.y)^2)
2 Likes

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

Thank you :blush:It's simpler and works~

Hi, bro, I have another question for help :smiling_face_with_tear:
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...