# 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...

``````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

From your answer ,I undersood the usage of the WITH Thank you It's simpler and works~
Hi, bro, I have another question for help 