From 7691e04ba5188a2b77761ffff8364728ff6cce52 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 15 Jan 2013 15:53:56 +0100 Subject: [PATCH] =?utf8?q?Nach=20L=C3=B6schen=20in=20customer/vendor=20via?= =?utf8?q?=20DB-Trigger=20in=20contacts,=20shipto=20aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...cleanup_after_customer_vendor_deletion.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sql/Pg-upgrade2/cleanup_after_customer_vendor_deletion.sql diff --git a/sql/Pg-upgrade2/cleanup_after_customer_vendor_deletion.sql b/sql/Pg-upgrade2/cleanup_after_customer_vendor_deletion.sql new file mode 100644 index 000000000..76d68b7a7 --- /dev/null +++ b/sql/Pg-upgrade2/cleanup_after_customer_vendor_deletion.sql @@ -0,0 +1,24 @@ +-- @tag: cleanup_after_customer_vendor_deletion +-- @description: Nach Löschen von Kunden/Lieferanten via Trigger auch Ansprechpersonen/Lieferadressen löschen +-- @depends: release_3_0_0 +-- @charset: utf-8 +CREATE OR REPLACE FUNCTION clean_up_after_customer_vendor_delete() RETURNS trigger AS $$ + BEGIN + DELETE FROM contacts + WHERE cp_cv_id = OLD.id; + + DELETE FROM shipto + WHERE (trans_id = OLD.id) + AND (module = 'CT'); + + RETURN OLD; + END; +$$ LANGUAGE plpgsql; + +CREATE TRIGGER after_delete_customer_trigger +AFTER DELETE ON customer FOR EACH ROW EXECUTE +PROCEDURE clean_up_after_customer_vendor_delete(); + +CREATE TRIGGER after_delete_vendor_trigger +AFTER DELETE ON vendor FOR EACH ROW EXECUTE +PROCEDURE clean_up_after_customer_vendor_delete(); -- 2.20.1