Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION insert_operations_trigger()
- RETURNS TRIGGER AS
- $BODY$
- DECLARE
- SQL text;
- m RECORD;
- r macnoms.operations;
- BEGIN
- IF EXISTS (SELECT 1 FROM macnoms.operations WHERE opnum=NEW.opnum) THEN
- SELECT INTO r * FROM macnoms.operations WHERE opnum=NEW.opnum;
- NEW.lastmod := NULL;
- r.lastmod:=NULL;
- IF ROW(r.*) IS DISTINCT FROM ROW(NEW.*) OR NOT(r.the_geom ~ NEW.the_geom AND st_equals(r.the_geom,NEW.the_geom)) THEN
- DELETE FROM macnoms.operations WHERE opnum=NEW.opnum;
- ELSE
- RETURN NULL;
- END IF;
- END IF;
- NEW.lastmod=now();
- RETURN NEW;
- END;
- $BODY$
- LANGUAGE plpgsql VOLATILE
- COST 100;
- ALTER FUNCTION insert_operations_trigger() OWNER TO pgsql;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement