Problem with syntax error at or near 'select'

1.7k views Asked by At

I'm trying to code about how to create isochrones, this is my code:

SELECT i As time_access,
ST_SetSRID(pgr_pointsAsPolygon(
‘SELECT id, ST_X (geom) AS x, ST_Y (geom) As y
FROM dd_caserne
WHERE access_time <= ‘|| i :: text), 4326) As geom
FROM generate_series(60,300,60)
As i
ORDER BY i DESC;

And the error I am getting is as follows:

ERROR:  syntax error at or near "id"
LINE 4: ‘SELECT id, ST_X (geom) AS x, ST_Y (geom) As y

can someone help me ?

1

There are 1 answers

2
Jim Jones On

Welcome to SO.

You're using a wrong character to quote the SELECT string. Use single quotes ' instead of ´:

SELECT 
  i AS time_access,
  ST_SetSRID(pgr_pointsAsPolygon(
    'SELECT id, ST_X(geom) AS x, ST_Y(geom) AS y
     FROM dd_caserne WHERE access_time <= '|| i::text), 4326) AS geom
FROM generate_series(60,300,60) AS i
ORDER BY i DESC;

See also dollar-quoted strings

Note: if you're using pgRouting 3.0+ please check pgr_alphaShape