I've a PostgreSQL schema containing two PostGIS tables ('points' and 'polygons'):
CREATE TABLE points ( gid serial NOT NULL, geom geometry(point, SRID), attribute_1 varchar(255), attribute_2 varchar(255), CONSTRAINT points_pkey PRIMARY KEY (gid) ); CREATE TABLE polygons ( gid serial NOT NULL, geom geometry(polygon, SRID), attribute_1 varchar(255), attribute_2 varchar(255), CONSTRAINT polygons_pkey PRIMARY KEY (gid) ); When creating or moving a point geometry I want to execute a spatial query to select the values of the polygon attribute columns and insert them into the point attribute columns WHERE ST_Within(point.geom, polygon.geom) IS TRUE. How to do this by using a trigger?
CREATE TRIGGER sample_points_tg AFTER INSERT OR UPDATE ON points FOR EACH ROW EXECUTE PROCEDURE sample_points_tg_fn();
أكثر...
CREATE TABLE points ( gid serial NOT NULL, geom geometry(point, SRID), attribute_1 varchar(255), attribute_2 varchar(255), CONSTRAINT points_pkey PRIMARY KEY (gid) ); CREATE TABLE polygons ( gid serial NOT NULL, geom geometry(polygon, SRID), attribute_1 varchar(255), attribute_2 varchar(255), CONSTRAINT polygons_pkey PRIMARY KEY (gid) ); When creating or moving a point geometry I want to execute a spatial query to select the values of the polygon attribute columns and insert them into the point attribute columns WHERE ST_Within(point.geom, polygon.geom) IS TRUE. How to do this by using a trigger?
CREATE TRIGGER sample_points_tg AFTER INSERT OR UPDATE ON points FOR EACH ROW EXECUTE PROCEDURE sample_points_tg_fn();
أكثر...