Subject RE: RE: [firebird-support] A sql sentence to innactivate all triggers...
Author Nigel Weeks
Surely that's a dangerous thing to do...

I didn't think turning on and off triggers inside a transaction was
possible, or recommended.
Imagine how much damage you could do if you could turn off triggers in a
multi-user environment...

Imagine your company's bean-counters coming to you, saying the end of month
report is out, and they can't find why...you've got a lot of work ahead of
you...Yucky!!

N.

> -----Original Message-----
> From: Thomas Steinmaurer [mailto:ts@...]
> Sent: Tuesday, 12 October 2004 5:05 PM
> To: firebird-support@yahoogroups.com
> Subject: RE: RE: [firebird-support] A sql sentence to innactivate all
> triggers...
>
>
>
> > Yes, I use innactive triggers when I need to do a bach move, it is
> > faster that way, I do it trigger by trigger but in a
> database with 140
> > takes to much time, that's why I need a sql sentense to do
> it faster.
>
> Create the following selectable stored procedure in your database:
>
> SET TERM ^^ ;
> CREATE PROCEDURE PRO_GENERATETRIGGERSCRIPT (
> SETACTIVE SmallInt)
> returns (
> SQLSTATEMENT VarChar(255))
> AS
> declare variable trigger_name varchar(31);
> begin
> for select rdb$trigger_name from rdb$triggers where
> (rdb$system_flag = 0 or rdb$system_flag is null) order by 1
> into :trigger_name
> do
> begin
> SQLSTATEMENT = 'ALTER TRIGGER ' || trigger_name;
> if (setactive = 1) then
> SQLSTATEMENT = SQLSTATEMENT || ' ACTIVE;';
> else
> SQLSTATEMENT = SQLSTATEMENT || ' INACTIVE;';
> suspend;
> end
> end
> ^^
> SET TERM ; ^^
>
>
> Now, if you want to generate a SQL script which disables all triggers
> call it this way:
>
> select * from PRO_GENERATETRIGGERSCRIPT (0);
>
> or, if you want to enable all triggers, use it that way:
>
> select * from PRO_GENERATETRIGGERSCRIPT (1);
>
>
> Save the result set into a .sql file and execute it via isql.exe or
> your favourite admin/dev tool.
>
>
> HTH,
> Thomas Steinmaurer
> LogManager Series - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database and MS SQL Server
> Upscene Productions
> http://www.upscene.com
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/67folB/TM
> --------------------------------------------------------------
> ------~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> __________ NOD32 1.892 (20041012) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.nod32.com
>
>