I'm looking for all the points that are inside a polygon. The query works for me, but when I add them to a function plggsql I get an error.
Query Ok
SELECT id, the_geom
FROM vialidad
WHERE ST_Contains('POLYGON((-99.1981315612793 19.357945,-99.1981315612793 19.376003,-99.161634 19.376003,-99.161634 19.357945,-99.1981315612793 19.357945))', ST_AsText(the_geom));
When I add the query to the function plpgsql and the polygon that was created is in polygon variable.
EXECUTE 'SELECT id,the_geom FROM vialidad WHERE ST_Contains('||polygon||',ST_AsText(vialidad_cdmx_vertices_pgr.the_geom));'
INTO nodes
USING polygon;
Console Error
QUERY: SELECT id, the_geom FROM vialidad WHERE ST_Contains(POLYGON((-99.1981315612793 19.357945,-99.1981315612793 19.376003,-99.161634 19.376003,-99.161634 19.357945,-99.1981315612793 19.357945)),ST_AsText(the_geom));
CONTEXT: PL/pgSQL function get_nodes_between_two_lines(integer,integer) line 37 at EXECUTE ********** Error **********
ERROR: syntax error at or near "19.357945" SQL state: 42601
Many thanks in advance for any possible help.
polygonbetween single quotes?EXECUTE 'SELECT id,the_geom FROM vialidad WHERE ST_Contains('||quote_literal(polygon)||', ...: assuming thatpolygonis a WKT literal.