1 -- @tag: delete_cvars_on_trans_deletion_fix1
 
   2 -- @description: Bugfix 1 für das Löschen von benutzerdefinierten Variablen via Triggerfunktionen
 
   3 -- @depends: delete_cvars_on_trans_deletion
 
   5 -- 2.2. Nun die Funktionen, die als Trigger aufgerufen wird und die
 
   6 -- entscheidet, wie genau zu löschen ist:
 
   7 CREATE OR REPLACE FUNCTION delete_custom_variables_trigger()
 
  10     IF (TG_TABLE_NAME IN ('orderitems', 'delivery_order_items', 'invoice')) THEN
 
  11       PERFORM delete_custom_variables_with_sub_module('IC', TG_TABLE_NAME, old.id);
 
  14     IF (TG_TABLE_NAME = 'parts') THEN
 
  15       PERFORM delete_custom_variables_with_sub_module('IC', '', old.id);
 
  18     IF (TG_TABLE_NAME IN ('customer', 'vendor')) THEN
 
  19       PERFORM delete_custom_variables_with_sub_module('CT', '', old.id);
 
  22     IF (TG_TABLE_NAME = 'contacts') THEN
 
  23       PERFORM delete_custom_variables_with_sub_module('Contacts', '', old.cp_id);
 
  26     IF (TG_TABLE_NAME = 'project') THEN
 
  27       PERFORM delete_custom_variables_with_sub_module('Projects', '', old.id);