I'd like to disable a specific trigger on a table prior to inserting data into it, but without affecting other users that may be changing data in that same table. I can't find any documented way to do this. This is Oracle 11g.
The best solution I've been able to come up with is to create a session variable and have my application set that to some value that the trigger checks for prior to doing its work.
Obligatory anti-trigger comment: I hate triggers.
When this trigger is created, Oracle Database enables it automatically. You can subsequently disable the trigger with the following statement: ALTER TRIGGER update_job_history DISABLE; When the trigger is disabled, the database does not fire the trigger when an UPDATE statement changes an employee's job.
Triggers can be re-enabled by using ENABLE TRIGGER. DML triggers defined on tables can be also be disabled or enabled by using ALTER TABLE. Changing the trigger by using the ALTER TRIGGER statement enables the trigger.
In Object Explorer, connect to an instance of Database Engine and then expand that instance. Expand the database that you want, expand Tables, and then expand the table that contains the trigger that you want to disable. Expand Triggers, right-click the trigger to disable, and then click Disable.
Consider temporarily disabling a trigger if one of the following conditions is true: An object that the trigger references is not available. You must perform a large data load and want it to proceed quickly without firing triggers. You are loading data into the table to which the trigger applies.
Add a variable to an existing package spec (or create a new package):
enable_trigger boolean := true;
Surround the code in the trigger with:
if enable_trigger then end if;
When you want to "disable" the trigger set the variable to false.
A Best Practice would be to put the variable in the body and write a set procedure and a get function.
I dont think that disabling trigger is possible for a particular session is possible in oracle or other rdbms .
My solution is that ,if you know the CURRENT_USER or the session_id from which you login ,than you can put a condition in the trigger .
IF SYS_CONTEXT ('USERENV', 'CURRENT_USER') <> '<XYZ>' THEN
--do the operation
END IF;
This condition you need to put in your trigger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With