IT_info
IT_info

Reputation: 727

Compare operator error

I have the following query in plpgsql:

FOR _t IN EXECUTE 'select distinct_network_point.id AS network_point_id
           from distinct_network_point, all_points_ordered
           where road_id='||road_id||' AND distinct_network_point.point = all_points_ordered.point AND all_points_ordered.point != st_setsrid(st_makepoint('||new_point||'),4326)
           order by st_distance(all_points_ordered.point,st_setsrid(st_makepoint('||new_point||'),4326))
           limit 1'

For some it is giving me the following error:

enter image description here

If I use this <> operator it will give me this than:

enter image description here

Can anyone explain what it really mean?. The query works fine in sql.

Upvotes: 0

Views: 46

Answers (1)

Michael Fredrickson
Michael Fredrickson

Reputation: 37398

Since you're dealing with geometric types, neither the != or <> operators are valid.

Instead, please refer to the following list of geometric operators.

In this case, since you want to check that two points are not the same, I believe you can use the distance between operator, <->, and check if the distance between your two points is greater than some sort of very small epsilon value.

Something like:

AND all_points_ordered.point <-> st_setsrid(st_makepoint('||new_point||'),4326) > 0.0001

Upvotes: 1

Related Questions