Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Disabling triggers
A copy of this was sent to Sam Jordan <sjo_at_spin.ch>
(if that email address didn't require changing)
On Mon, 14 Jun 1999 14:30:49 +0000, you wrote:
>Hi
>
>Is there any way to disable a trigger programmatically, for example
>in a stored procedure? I'd like to disable a trigger, perform some
>SQL stuff and reenable it afterwards. For other statements the
>trigger shouldn't be deactivated.
>
>bye
alter trigger command will do that.
You might find it easier (and safer) to have a packge variable 'disable' the trigger. for example:
create or replace package my_globals
as
doTrigger boolean default TRUE;
end;
/
and then code the triggers as:
create or replace trigger ....
...
begin
if ( my_globals.doTrigger )
then
trigger logic goes here
end if;
end;
then, have your application issue:
begin my_globals.doTrigger := FALSE; end;
to 'disable' the trigger. that way, other concurrently executing sessions will ahve the trigger enabled and in the event the system goes down after you "disabled" the trigger but before you could enable it -- it will still be 'enabled' (not so with the alter trigger -- it will be disabled if your app crashes or the system goes down)
See http://www.oracle.com/ideveloper/ for my column 'Digging-in to Oracle8i'... Mirrored (and more current) at http://govt.us.oracle.com/~tkyte/
Current article is "Fine Grained Access Control", added June 8'th
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA--