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?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jul 12, 2022 at 1:44
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. Commented 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

answered Jul 12, 2022 at 9:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.