Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disable Triggers for each connection

71 views
Skip to first unread message

noand24

unread,
Jun 30, 2009, 11:26:42 AM6/30/09
to
I read the article here http://www.ibm.com/developerworks/db2/library/techarticle/0211yip/0211yip.html
But may be exists another way in db2 9.7 using variables for example?

Serge Rielau

unread,
Jun 30, 2009, 9:31:39 PM6/30/09
to
noand24 wrote:
> I read the article here http://www.ibm.com/developerworks/db2/library/techarticle/0211yip/0211yip.html
> But may be exists another way in db2 9.7 using variables for example?
yes. Starting in DB2 9.5 you can use a global variable.
E.g. (untested, may have sntax errors but you get the idea...)

CREATE VARIABLE triggersdisabled INTEGER DEFAULT 0;
GRANT READ ON VARIABLE triggersdisabled TO PUBLIC;
GRANT WRITE ON VARIABLE triggersdisabled TO USER itsme;

CREATE TABLE T(c1 INT);
CREATE TRIGGER trg BEFORE INSERT ON T REFERENCING NEW AS N FOR EACH ROW
WHEN (triggersdisabled = 0)
SET c1 = -c1;


Now itsme can SET triggersdisabled to 1 (true) for its connection.
everyone else will keep them.

Cheers
Serge

--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

0 new messages