I need to be able to catch when my postgresql database returns no rows
in a raw sql query.
In this case it would be an error indicating that the long and lat are
outside of the
shape file.
s = Boundary.find_by_sql(“SELECT name, country, stateabb FROM
boundaries WHERE distance( the_geom,‘POINT(#{@lon} #{@lat})’) = 0”)
testing with s.nil! does not seem to solve the problem
Any ideas?
Here are two queries one without a record and one with
SELECT name, country, stateabb FROM boundaries WHERE
distance( the_geom,‘POINT(-89.0 0.0)’) = 0;
name | country | stateabb
------±--------±---------
(0 rows)
SELECT name, country, stateabb FROM boundaries WHERE
distance( the_geom,‘POINT(-89.0 43.0)’) = 0;
name | country | stateabb
-----------±--------±---------
Wisconsin | USA | US-WI
(1 row)