I'm trying to import in a table with columns (name, x, y, geom) like this:
INSERT INTO public.table (name, x, y, geom)
VALUES ('name', X, Y, ST_GEOMFROMTEXT('POINT(X,Y)', SRC))
But I'm obtaining this error:
ERROR: parse error - invalid geometry SQL state: XX000
X, Y and SRC are integers. I've wrote X and Y as generic.
What's going on?
-
1WKT only uses commas between vertices, not within them. You've presented a single part point with two vertices, but only one dimension each.Vince– Vince2022年07月12日 01:51:18 +00:00Commented Jul 12, 2022 at 1:51
1 Answer 1
In PostGIS, to insert a geometry/point into a table ('table' in your case), by converting its WKT value, you rather use this :
INSERT INTO public.table (name, x, y, geom)
VALUES ('name', X, Y, ST_GEOMFROMTEXT('POINT(X Y)', SRC))
The X and Y values should not be separated by a comma. Take a look at the official documentation : ST_GeomFromText