Revision 7691e04b
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
sql/Pg-upgrade2/cleanup_after_customer_vendor_deletion.sql | ||
---|---|---|
1 |
-- @tag: cleanup_after_customer_vendor_deletion |
|
2 |
-- @description: Nach Löschen von Kunden/Lieferanten via Trigger auch Ansprechpersonen/Lieferadressen löschen |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
-- @charset: utf-8 |
|
5 |
CREATE OR REPLACE FUNCTION clean_up_after_customer_vendor_delete() RETURNS trigger AS $$ |
|
6 |
BEGIN |
|
7 |
DELETE FROM contacts |
|
8 |
WHERE cp_cv_id = OLD.id; |
|
9 |
|
|
10 |
DELETE FROM shipto |
|
11 |
WHERE (trans_id = OLD.id) |
|
12 |
AND (module = 'CT'); |
|
13 |
|
|
14 |
RETURN OLD; |
|
15 |
END; |
|
16 |
$$ LANGUAGE plpgsql; |
|
17 |
|
|
18 |
CREATE TRIGGER after_delete_customer_trigger |
|
19 |
AFTER DELETE ON customer FOR EACH ROW EXECUTE |
|
20 |
PROCEDURE clean_up_after_customer_vendor_delete(); |
|
21 |
|
|
22 |
CREATE TRIGGER after_delete_vendor_trigger |
|
23 |
AFTER DELETE ON vendor FOR EACH ROW EXECUTE |
|
24 |
PROCEDURE clean_up_after_customer_vendor_delete(); |
Auch abrufbar als: Unified diff
Nach Löschen in customer/vendor via DB-Trigger in contacts, shipto aufräumen