SHOW:
|
|
- or go back to the newest paste.
1 | CREATE or Replace FUNCTION func_geom_insert() RETURNS trigger AS $func_geom_insert$ | |
2 | DECLARE | |
3 | results RECORD; | |
4 | BEGIN | |
5 | FOR results IN SELECT * FROM geometries ORDER BY name LOOP | |
6 | - | IF st_overlaps(results.geom,NEW.geom) OR st_contains(results.geom,NEW.geom) OR st_crosses(results.geom,NEW.geom) OR st_covers(results.geom,NEW.geom) OR st_touches(results.geom,NEW.geom) OR st_equals(results.geom,NEW.geom) THEN |
6 | + | IF ST_Intersects(results.geom,NEW.geom) OR st_overlaps(results.geom,NEW.geom) OR st_contains(results.geom,NEW.geom) OR st_crosses(results.geom,NEW.geom) OR st_covers(results.geom,NEW.geom) OR st_touches(results.geom,NEW.geom) OR st_equals(results.geom,NEW.geom) THEN |
7 | insert into geometries1(name,geom) values(NEW.name,NEW.geom); | |
8 | EXIT; | |
9 | END IF; | |
10 | END LOOP; | |
11 | return null; | |
12 | END; | |
13 | $func_geom_insert$ LANGUAGE plpgsql; | |
14 | - | CREATE TRIGGER t_insert_2_table AFTER INSERT ON geometries |
14 | + | CREATE TRIGGER t_insert_2_table BEFORE INSERT ON geometries |
15 | FOR EACH ROW EXECUTE PROCEDURE func_geom_insert(); |