Subject | RE: RE: [firebird-support] A sql sentence to innactivate all triggers... |
---|---|
Author | Thomas Steinmaurer |
Post date | 2004-10-12T06:04:44Z |
> Yes, I use innactive triggers when I need to do a bach move, it isCreate the following selectable stored procedure in your database:
> 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.
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