Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Disabling triggers

Re: Disabling triggers

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 14 Jun 1999 15:39:04 GMT
Message-ID: <37702178.12502447@newshost.us.oracle.com>


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
--
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Jun 14 1999 - 10:39:04 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US