I have this Postgres/PostGIS query:
UPDATE raw.geocoding
SET the_geom = ST_Transform(ST_GeomFromText('POINT(((E'-96.6864379495382')::float8) ((E'32.792527154088')::float8))', 4326),3081)
WHERE id=((10793455)::int4)
When I run it, I get this error:
ERROR: syntax error at or near "')::float8) ((E'"
LINE 2: ...sform(ST_GeomFromText('POINT(((E'-96.6864379495382')::float8...
^
********** Error **********
ERROR: syntax error at or near "')::float8) ((E'"
SQL state: 42601
Character: 94
I’m scratching my head because PostGIS doesn’t have a problem with escaped data (for example), and the query was generated from npgsql based on this parameterized query:
UPDATE raw.geocoding
SET the_geom = ST_Transform(ST_GeomFromText('POINT(:longitude :latitude)', 4326),3081)
WHERE id=:id
I am running Postgres 9.1.5 and PostGIS 2.0.1.
The error results from unescaped single quotes in the string. The standard way is to double them:
This fixes the string literal, but you have more errors.
Like @Paul hinted in a comment,
ST_GeomFromText()expects the geometry WKTPOINT(0 0). The explicit cast tofloat8makes it look like you are trying to enter the Postgres functionpoint()(had me confused at first). Simplify to:Note also, how I use dollar quoting in the second example to avoid having to escape single quotes altogether. As there aren’t any single quotes left in your string literal after fixing the syntax, you might as well use single quotes again. Your parametrized query:
You can add a cast to
geometryto make it clear, like @Paul advises in his comment. But it works without explicit cast, too.