473,569 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7128
"Mary" <db*****@yahoo. com> wrote in message
news:cb******** *************** ***@posting.goo gle.com...
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.goo gle.com...
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.e ye-bee-m.com> wrote in message news:<br******* ***@hanover.tor olab.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 <constraintsche ck> <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
3439
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 ( @foobar = 'foobar') INSERT INTO LogTable (LogText) values ('Found foobar')
3
16320
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 procedure that essentially inserts in the orders table the mail order, and then insert multiple orderdetails within the same transaction. I also need to do...
6
2476
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. EXEC @Status = master..xp_sendmail @recipients=@TOList, @copy_recipients=@CCList,@subject='the subject goes here',@message=@MailText,@no_output=TRUE
10
2053
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 values of 7 singular "day" fields. Here is what I have come up with using the TSQL documentation. CREATE TRIGGER trigger_stocksum ON tblStock FOR...
0
2461
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 I've found it educational. Note: - I build this for use in a JDEdwards OneWorld environment. I'm not sure how generic others find it but it...
5
5608
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 and the database hasn't been updated then it's a huge mess. No problem right? Just document the changes to the database that you made and then...
7
4265
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 the initial values of all columns as of the INSERT, in the form of UPDATEs w/ NULL old values. I pass (amongst other things) a table name and a...
1
2592
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 integrity problems "The INSERT statement conflicted with the FOREIGN KEY constraint..." if the identity/primary key column is "out of sync" with the...
8
7867
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 to upload/download changes. I have a trigger set up on one table which updates another, here is an example of the trigger: "CREATE TRIGGER...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.