1

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?

1
  • 1
    WKT only uses commas between vertices, not within them. You've presented a single part point with two vertices, but only one dimension each.
    – Vince
    Jul 12, 2022 at 1:51

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.