From 5c49e28ba1e7b146d94bb66bf8fa7a4a5a591a49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 9 Oct 2012 14:19:01 +0200 Subject: [PATCH] Syntaxkorrektur zu den record_links triggern --- .../record_links_post_delete_triggers2.sql | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sql/Pg-upgrade2/record_links_post_delete_triggers2.sql diff --git a/sql/Pg-upgrade2/record_links_post_delete_triggers2.sql b/sql/Pg-upgrade2/record_links_post_delete_triggers2.sql new file mode 100644 index 000000000..70967f9f3 --- /dev/null +++ b/sql/Pg-upgrade2/record_links_post_delete_triggers2.sql @@ -0,0 +1,40 @@ +-- @tag: record_links_post_delete_triggers2 +-- @description: PL/PgSQL Syntax Fix +-- @depends: record_links_post_delete_triggers +-- @encoding: utf8 + +CREATE OR REPLACE FUNCTION clean_up_record_links_before_oe_delete() RETURNS trigger AS $$ + BEGIN + DELETE FROM record_links + WHERE (from_table = 'oe' AND from_id = OLD.id) + OR (to_table = 'oe' AND to_id = OLD.id); + RETURN OLD; + END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION clean_up_record_links_before_delivery_orders_delete() RETURNS trigger AS $$ + BEGIN + DELETE FROM record_links + WHERE (from_table = 'delivery_orders' AND from_id = OLD.id) + OR (to_table = 'delivery_orders' AND to_id = OLD.id); + RETURN OLD; + END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION clean_up_record_links_before_ar_delete() RETURNS trigger AS $$ + BEGIN + DELETE FROM record_links + WHERE (from_table = 'ar' AND from_id = OLD.id) + OR (to_table = 'ar' AND to_id = OLD.id); + RETURN OLD; + END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION clean_up_record_links_before_ap_delete() RETURNS trigger AS $$ + BEGIN + DELETE FROM record_links + WHERE (from_table = 'ap' AND from_id = OLD.id) + OR (to_table = 'ap' AND to_id = OLD.id); + RETURN OLD; + END; +$$ LANGUAGE plpgsql; -- 2.20.1