Syntaxkorrektur zu den record_links triggern
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 9 Oct 2012 12:19:01 +0000 (14:19 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Tue, 9 Oct 2012 12:19:01 +0000 (14:19 +0200)
sql/Pg-upgrade2/record_links_post_delete_triggers2.sql [new file with mode: 0644]

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 (file)
index 0000000..70967f9
--- /dev/null
@@ -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;