Subject | RE: [firebird-support] How can I run an "Update Table" with no triggers? |
---|---|
Author | Nigel Weeks |
Post date | 2006-12-08T03:33:55Z |
Here's a working example.
(You don't have to do the logging - I just like to know when things get
executed, as triggers can be tricky critters to trace the execution of.)
CREATE TABLE tbl_app (
int_appid INTEGER NOT NULL,
str_name VARCHAR(128) NOT NULL,
str_url1 VARCHAR(256),
PRIMARY KEY(int_appid)
);
CREATE TABLE tbl_log (
dtm_stamp TIMESTAMP DEFAULT 'now' NOT NULL,
str_log VARCHAR(1024)
);
SET TERM !! ;
CREATE OR ALTER TRIGGER MMK$APP
FOR TBL_APP
ACTIVE
BEFORE INSERT OR UPDATE OR DELETE
POSITION 100
AS
DECLARE VARIABLE str_logging VARCHAR(1024);
BEGIN
IF ( CURRENT_USER = 'replication' ) THEN
BEGIN
str_logging = 'DEBUG: MMK$APP launched as replication. Skipping
active section.';
END
ELSE
BEGIN
str_logging = 'DEBUG: MMK$APP launched as a normal user';
/* ----------------------------------------------
* Put in all your active section from this point on
* ----------------------------------------------
*/
/* ----------------------------------------------
* End of Active Trigger Section
* ----------------------------------------------
*/
END
/* Write the logging field to the log file */
insert into tbl_log(str_log) values (:str_logging);
END !!
SET TERM ; !!
Nige.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]On Behalf Of Fabian Chocron
Sent: Friday, 8 December 2006 1:44 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How can I run an "Update Table" with no
triggers?
Thanks Nige!
How can I retrieve the current user, and therefore skip the trigger ?
I guess something like:
if Current_user <> 'XXX' then |
BEGIN
TRIGGER
END
Fabian
(You don't have to do the logging - I just like to know when things get
executed, as triggers can be tricky critters to trace the execution of.)
CREATE TABLE tbl_app (
int_appid INTEGER NOT NULL,
str_name VARCHAR(128) NOT NULL,
str_url1 VARCHAR(256),
PRIMARY KEY(int_appid)
);
CREATE TABLE tbl_log (
dtm_stamp TIMESTAMP DEFAULT 'now' NOT NULL,
str_log VARCHAR(1024)
);
SET TERM !! ;
CREATE OR ALTER TRIGGER MMK$APP
FOR TBL_APP
ACTIVE
BEFORE INSERT OR UPDATE OR DELETE
POSITION 100
AS
DECLARE VARIABLE str_logging VARCHAR(1024);
BEGIN
IF ( CURRENT_USER = 'replication' ) THEN
BEGIN
str_logging = 'DEBUG: MMK$APP launched as replication. Skipping
active section.';
END
ELSE
BEGIN
str_logging = 'DEBUG: MMK$APP launched as a normal user';
/* ----------------------------------------------
* Put in all your active section from this point on
* ----------------------------------------------
*/
/* ----------------------------------------------
* End of Active Trigger Section
* ----------------------------------------------
*/
END
/* Write the logging field to the log file */
insert into tbl_log(str_log) values (:str_logging);
END !!
SET TERM ; !!
Nige.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]On Behalf Of Fabian Chocron
Sent: Friday, 8 December 2006 1:44 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How can I run an "Update Table" with no
triggers?
Thanks Nige!
How can I retrieve the current user, and therefore skip the trigger ?
I guess something like:
if Current_user <> 'XXX' then |
BEGIN
TRIGGER
END
Fabian
----- Original Message -----
From: "Nigel Weeks" <nweeks@...>
To: <firebird-support@yahoogroups.com>
Sent: Friday, December 08, 2006 1:00 PM
Subject: RE: [firebird-support] How can I run an "Update Table" with no
triggers?
> You'll have to inactive the triggers before you do the update.
>
> Alternatively, and this will take a bit of preparation, I've created my
> triggers with a check at the top, and if a certain user, in my case
> 'replication' does an operation, the trigger skips it's active section.
>
> Perhaps, fi you're going to do this operation frequently, modify your
> triggers to test for a different connected user, and do your operations
as
> this alternative user to bypass the triggers.
>
> Nige.
>
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com]On Behalf Of fabianchocron
> Sent: Friday, 8 December 2006 12:52 PM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] How can I run an "Update Table" with no
> triggers?
>
>
> I wonder if it's possible to run an Update on a Table but without
> executing all triggers?
> Something like
>
> Update Invoices "With no Triggers"
> set Total_Amount = 0
> where clientcode = '123'
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
[Non-text portions of this message have been removed]