Disable trigger : Utility Procedure « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PROCEDURE settrig (tab IN VARCHAR2,action IN VARCHAR2) IS
  2     v_action VARCHAR2 (10) := UPPER (action);
  3     v_other_action VARCHAR2 (10) := 'DISABLE';
  4  BEGIN
  5     IF v_action = 'DISABLE'
  6     THEN
  7        v_other_action := 'ENABLE';
  8     END IF;
  9     FOR rec IN (SELECT trigger_name
 10                   FROM user_triggers
 11                  WHERE table_owner = USER
 12                    AND table_name = UPPER (tab)
 13                    AND status = v_other_action)
 14     LOOP
 15        EXECUTE IMMEDIATE 'ALTER TRIGGER ' || rec.trigger_name || ' ' || v_action;
 16        DBMS_OUTPUT.put_line ('Set status of ' || rec.trigger_name || ' to ' || v_action);
 17     END LOOP;
 18  END;
 19  /

Procedure created.

SQL>








27.28.Utility Procedure
27.28.1.Don't display lines longer than 80 characters
27.28.2.Create procedure for displaying long text line by line
27.28.3.Procedure create_order
27.28.4.A package to calculate your age
27.28.5.Disable trigger
27.28.6.Returns the total from an order number being passed in.
27.28.7.Dynamically perform any DDL statements from within your normal PL/SQL processing.
27.28.8.Execuate the same SQL in two ways: static way and dynamic way