Reputation: 139
I am having some trouble trying to update a field.
I created a column as text
and stored many rows with (lon,lat)
. Now I have created one more field as Geometry(Polygon)
and I am trying to update it unsuccessfully.
The data is stored like this:
POLYGON ((-16.6318775869111 -52.5925428149806, -16.6346393504709 -52.572542814981
, -16.629462102066 -52.5525428149806, -16.6255191065928 -52.5455420519144
, -16.6055191065928 -52.5488828022871, -16.6021791014778 -52.552542814981
, -16.6108484688169 -52.5925428149806, -16.6255191065928 -52.599495926874
, -16.6318775869111 -52.5925428149806))
I am trying this command
UPDATE field_as_text
SET field_as_geomtry = SELECT ST_GeomFromText(SELECT field_as_text);
I am getting this error message
ERROR: syntax error at or near "select" LINE 1: ... set field_as_geomtry = select (ST...
Could anyone enlighten me?
Upvotes: 1
Views: 6264
Reputation: 656734
You need to start by reading the manual about the SQL UPDATE
command.
Should look something like this:
UPDATE table_name
SET field_as_geomtry = ST_GeomFromText(field_as_text);
Upvotes: 4