2012-06-14 154 views
1

我需要將多邊形插入到postgresql表「polygontable」中,然後返回其(the_geom)值以供進一步查詢。我想要抓住「polygontable」中最近插入的實例。如何在SELECT語句中調用返回的「polygongeom」?從select語句中調用返回值

INSERT INTO polygontable (the_geom) 
VALUES (ST_SetSRID((ST_MakeValid(ST_GeomFromGeoJSON('"+JSON.stringify(payload)+"'))),4326)) returning the_geom as polygon_geom; 

SELECT st_intersects(polygon_geom, other_table.the_geom) 
from polygon_geom, other_table; 

回答

2

如果你是9.1,你可以做這樣的事情:

with inserted as 
(
    insert into ... 
    returning the_geom as new_geom 
) 
SELECT st_intersects(inserted.new_geom, other_table.the_geom) 
from inserted, other_table;