From: Sven Schöling Date: Tue, 9 Oct 2012 12:19:01 +0000 (+0200) Subject: Syntaxkorrektur zu den record_links triggern X-Git-Tag: release-3.0.0beta1~225^2~9 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5c49e28ba1e7b146d94bb66bf8fa7a4a5a591a49;p=kivitendo-erp.git Syntaxkorrektur zu den record_links triggern --- 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;