473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DB2 multiple trigger activation order for column UPDATEs

We are developing a DB2 V7 z/OS application which uses a "trigger"
table containing numerous triggers - each of which is activated by an
UPDATE to a different column of this "trigger" table. When the
triggers are fired, various other operations are performed on other
tables in the database. The triggers are not created on these other
tables because other programs perform updates to these tables and we
do not want the triggers to fire for them. There is no trigger
cascading.

The problem appears to be that, even though different columns control
the trigger activation, any UPDATE to the "trigger" table causes
trigger execution to proceed in the order of trigger creation. For
example:

CREATE TRIGGER Trigger 1
AFTER UPDATE OF AA
ON TFP_TRIGGERS

CREATE TRIGGER Trigger 2
AFTER UPDATE OF BB
ON TFP_TRIGGERS
Although AA and BB are updated independently, Trigger 2 (newer
timestamp) waits until Trigger 1 has completed. So even though the
triggers seem to have different triggering events, DB2 appears to be
treating both triggers as having the same triggering event. Is there
any way to have trigger activation controlled at the column level so
that both triggers can be activated independently and run
simultaneously?
Nov 12 '05 #1
6 7111
"Mary" <db*****@yahoo.com> wrote in message
news:cb**************************@posting.google.c om...
We are developing a DB2 V7 z/OS application which uses a "trigger"
table containing numerous triggers - each of which is activated by an
UPDATE to a different column of this "trigger" table. When the
triggers are fired, various other operations are performed on other
tables in the database. The triggers are not created on these other
tables because other programs perform updates to these tables and we
do not want the triggers to fire for them. There is no trigger
cascading.

The problem appears to be that, even though different columns control
the trigger activation, any UPDATE to the "trigger" table causes
trigger execution to proceed in the order of trigger creation. For
example:

CREATE TRIGGER Trigger 1
AFTER UPDATE OF AA
ON TFP_TRIGGERS

CREATE TRIGGER Trigger 2
AFTER UPDATE OF BB
ON TFP_TRIGGERS
Although AA and BB are updated independently, Trigger 2 (newer
timestamp) waits until Trigger 1 has completed. So even though the
triggers seem to have different triggering events, DB2 appears to be
treating both triggers as having the same triggering event. Is there
any way to have trigger activation controlled at the column level so
that both triggers can be activated independently and run
simultaneously?


Are both updates (to AA and BB) done within the same unit of work (i.e., no
commit is done until both updates take place)?
Nov 12 '05 #2
Yes - they are in the same unit of work. This is a requirement of the application.

"Mark A" <ma@switchboard.net> wrote in message news:<M0*****************@news.uswest.net>...
"Mary" <db*****@yahoo.com> wrote in message
news:cb**************************@posting.google.c om...
We are developing a DB2 V7 z/OS application which uses a "trigger"
table containing numerous triggers - each of which is activated by an
UPDATE to a different column of this "trigger" table. When the
triggers are fired, various other operations are performed on other
tables in the database. The triggers are not created on these other
tables because other programs perform updates to these tables and we
do not want the triggers to fire for them. There is no trigger
cascading.

The problem appears to be that, even though different columns control
the trigger activation, any UPDATE to the "trigger" table causes
trigger execution to proceed in the order of trigger creation. For
example:

CREATE TRIGGER Trigger 1
AFTER UPDATE OF AA
ON TFP_TRIGGERS

CREATE TRIGGER Trigger 2
AFTER UPDATE OF BB
ON TFP_TRIGGERS
Although AA and BB are updated independently, Trigger 2 (newer
timestamp) waits until Trigger 1 has completed. So even though the
triggers seem to have different triggering events, DB2 appears to be
treating both triggers as having the same triggering event. Is there
any way to have trigger activation controlled at the column level so
that both triggers can be activated independently and run
simultaneously?


Are both updates (to AA and BB) done within the same unit of work (i.e., no
commit is done until both updates take place)?

Nov 12 '05 #3
AK
Mary,

TRIGGERS IN db2 ARE INLINE, I.E. THEY ARE COMPILED into the UPDATE
statement that fires the triggers. Just have a look at the execution
plan and see for yourself.

I guess you are thinking of parallellism because something runs
slowly. I'd rather post the performance problem
Nov 12 '05 #4
Actually triggers in DB2 z/OS are stored procedures.
It is only DB2 for Multiplatforms that inlines triggers.
Either way the SQL Standard requires Trigger A to finish before Trigger
B starts. Otherwise you could get funky semantics.
In theory a DBMS could analyse the triggers, detect there are no
conflicts and then parallelize execution.
I'm not aware of a product that does that.

Cheers
Serge

Nov 12 '05 #5
Thank you. Just for clarification - Does this mean that all trigger
execution is serialized when different programs running in parallel
activate multiple column triggers defined on the same table
simultaneously?

If so, would it solve our problem to move the triggers out of the
"trigger" table and create them separately on each of the tables
needing processing? We would need to code the WHEN clause to limit
the triggered action to a specific user so that the trigger bodies
would not execute for other applications. Any other ideas or
suggestions would be welcome.

Serge Rielau <sr*****@ca.eye-bee-m.com> wrote in message news:<br**********@hanover.torolab.ibm.com>...
Actually triggers in DB2 z/OS are stored procedures.
It is only DB2 for Multiplatforms that inlines triggers.
Either way the SQL Standard requires Trigger A to finish before Trigger
B starts. Otherwise you could get funky semantics.
In theory a DBMS could analyse the triggers, detect there are no
conflicts and then parallelize execution.
I'm not aware of a product that does that.

Cheers
Serge

Nov 12 '05 #6
Hi Mary,

What I wrote only referred to a single connection.
If you run, say, an update statement which fires triggerA and triggerB
Then the order is: UPDATE <constraintscheck> <triggerA> <triggerB>
Concurrent connections are handled as usual and appropriately to you
isolation level.

I can't comment on you "trigger-table" since I don't knwo DB2 z/OS
catalog structure.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dave C. | last post by:
Hello, I have created the following trigger: CREATE TRIGGER tr_UDFTest ON UserDefinedFields FOR INSERT, UPDATE AS DECLARE @foobar varchar(100) SELECT @foobar= foobar FROM inserted IF (...
3
by: JB | last post by:
To anyone that is able to help.... What I am trying to do is this. I have two tables (Orders, and OrderDetails), and my question is on the order details. I would like to set up a stored...
6
by: Rolf Kemper | last post by:
Dear All, we are running SQL2000 Sever and make use of the xp_sendmail. For any reason the mail service can run into problems and it looks like that the statemnt below gets not finished. ...
10
by: Axel | last post by:
Hello, I would like to create a (what I believe is) simple trigger that updates a row in one table based on updates of corresponding fields of same row. Its a "week total" field that sums up...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
5
by: keith.culpepper | last post by:
Can anyone please provide some assistance with a trigger that I need to develop. Here is the situation: Our program updates depend on database updates. If a client receives the program update...
7
by: aj | last post by:
DB2 LUW 8.2 FP5 (or is it 8.1 FP11?) I am CALLing a stored procedure from a trigger in order to maintain a column-level audit trail. Not only do I need to store a record of the INSERT, but also...
1
by: Magnus | last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables). http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx In the famous Customer/Order example, I'm getting referential...
8
by: Benzine | last post by:
Hi, I have an issue with my replication at the moment. I will try to describe the scenario accurately. I am using MS SQL 2000 SP4 with Merge Replication. Subscribers connect to the publisher...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.