Sunday, 15 April 2012

postgresql - Unable to INSERT between tables using ST_GeomFromText -


I am trying to insert point geometry values ​​and other data from one table to another.

  - Create table bh_tmp (bh_id integer, bh_name varchar, first decimal, answer decimal, ground_mod decimal); Make the table bh (name varchar); SELECT AddGeometryColumn ('bh', 'bh_geom', 27700, 'POINT', 3); - Populi in bh_tmp values ​​(1, 'C5', 542945.0,180846.0,3.947), (3, 'b24', 542850.0,180850.04.020), (4, 'b 26', 543020.0,180850.04.020) Bh_tmp insert; - BH (name, bh_jim) by bHttp by BHTP, SELECT bh_name, CONCAT ($$ ST_GeomFromText ('POINT ($$, ESTING,', NORTHING, '', GroundMOD, $$) ', 27700) $ $ ); From Bh_tmp;  

returns this error:

  Error: parse error - invalid geometry SQL state: XX000 sign: "ST" & lt; - Parsing error in geometry at position 2  

I can not see anything wrong with the ST_GeomFromText string I have specified but I I can populate the table bh if I manually insert rows, such as:

  INSERT bh (name, bh_geom) VALUES ('C5' ST_GeomFromText ('POINT (542945.0 180846.0.3 9 47)', 27700);  

What am I doing?

You are receiving this error because the output of the CONCAT function is the text, and your bh_geom column is geometry, Therefore, you are trying to insert text in geometry, it will work:

  INSERT INTO bh (name, bh_geom) SELECT bh_name, ST_GeomFromText ('POINT ('; east ' || Answering || '' || Ground_mod || '' ', 27700) from bh_tmp;  

No comments:

Post a Comment