CREATE OR REPLACE PROCEDURE plch_set_trigger_status (tab IN VARCHAR2
, sch IN VARCHAR DEFAULT NULL
, action IN VARCHAR2
, name_filter IN VARCHAR2 := '%'
)
IS
PRAGMA AUTONOMOUS_TRANSACTION;
l_action VARCHAR2 (10) := UPPER (action);
l_other_action VARCHAR2 (10) := 'DISABLED';
BEGIN
IF l_action IN ('D', 'DISABLED', 'DISABLE', 'DIS')
THEN
l_other_action := 'ENABLED';
END IF;
FOR rec
IN (SELECT trigger_name
FROM user_triggers
WHERE table_owner = UPPER (NVL (sch, USER))
AND table_name = tab
AND status = l_other_action
AND trigger_name LIKE name_filter)
LOOP
EXECUTE IMMEDIATE 'ALTER TRIGGER '
|| rec.trigger_name
|| ' '
|| l_action;
DBMS_OUTPUT.put_line (
'Status of ' || rec.trigger_name || ' set to ' || l_action
);
END LOOP;
END;