From c42bd9c2d915cc36b91801311fe751a833efef54 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 12 Nov 2014 12:01:09 +0100 Subject: [PATCH] =?utf8?q?Benutzerdefinierte=20Variablen=20via=20Trigger?= =?utf8?q?=20l=C3=B6schen=20Bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Die ID-Spalte heißt in der contacts-Tabelle cp_id und nicht id. --- .../delete_cvars_on_trans_deletion_fix1.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sql/Pg-upgrade2/delete_cvars_on_trans_deletion_fix1.sql diff --git a/sql/Pg-upgrade2/delete_cvars_on_trans_deletion_fix1.sql b/sql/Pg-upgrade2/delete_cvars_on_trans_deletion_fix1.sql new file mode 100644 index 000000000..291cc5fb5 --- /dev/null +++ b/sql/Pg-upgrade2/delete_cvars_on_trans_deletion_fix1.sql @@ -0,0 +1,32 @@ +-- @tag: delete_cvars_on_trans_deletion_fix1 +-- @description: Bugfix 1 für das Löschen von benutzerdefinierten Variablen via Triggerfunktionen +-- @depends: delete_cvars_on_trans_deletion + +-- 2.2. Nun die Funktionen, die als Trigger aufgerufen wird und die +-- entscheidet, wie genau zu löschen ist: +CREATE OR REPLACE FUNCTION delete_custom_variables_trigger() +RETURNS TRIGGER AS $$ + BEGIN + IF (TG_TABLE_NAME IN ('orderitems', 'delivery_order_items', 'invoice')) THEN + PERFORM delete_custom_variables_with_sub_module('IC', TG_TABLE_NAME, old.id); + END IF; + + IF (TG_TABLE_NAME = 'parts') THEN + PERFORM delete_custom_variables_with_sub_module('IC', '', old.id); + END IF; + + IF (TG_TABLE_NAME IN ('customer', 'vendor')) THEN + PERFORM delete_custom_variables_with_sub_module('CT', '', old.id); + END IF; + + IF (TG_TABLE_NAME = 'contacts') THEN + PERFORM delete_custom_variables_with_sub_module('Contacts', '', old.cp_id); + END IF; + + IF (TG_TABLE_NAME = 'project') THEN + PERFORM delete_custom_variables_with_sub_module('Projects', '', old.id); + END IF; + + RETURN old; + END; +$$ LANGUAGE plpgsql; -- 2.20.1