If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Problem in 'AFTER UPDATE... FOR EACH ROW' TRIGGER

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-03, 13:00
dilip dilip is offline
Registered User
 
Join Date: Nov 2003
Location: India
Posts: 3
Problem in 'AFTER UPDATE... FOR EACH ROW' TRIGGER

Hi,

I have defined the trigger GIVEN BELOW "AFTER UPDATE", "FOR EACH ROW" .

Whenever I updated a single row on the table, if the WHEN condition is satisfied, the trigger is fired and record is inserted into the table.

However when I performed an UPDATE on the table, in way that it would effect '10' rows, the trigger is not getting fired '10' times. THIS IS ACTUALLY HAPPENING WHEN THE 'WHEN CONDITION' IS FAILING FOR ATLEAST ONE UPDATED ROW.

IF THE WHEN CONDITION IS SATISFIED FOR ALL THE 10 UPDATED ROWS THEN THE TRIGGER IS FIRED 10 TIMES AND 10 INSERTS ARE DONE.

What could be the possible reason. Pls help.


CREATE TRIGGER T_TABLE_A
AFTER UPDATE
OF A_COST
ON TABLE_A
REFERENCING OLD AS O_ROW
FOR EACH ROW MODE DB2SQL
WHEN (1 <> (
SELECT 1
FROM SYSIBM.SYSDUMMY1
WHERE EXISTS
(
SELECT 1
FROM TABLE_B
WHERE B_ITEM = O_ROW.A_ITEM
)
)
)
BEGIN ATOMIC
INSERT
INTO TABLE_B
( B_ITEM
,B_COST
)
VALUES ( O_ROW.A_ITEM
,O_ROW.A_COST
);
END#


Regards
Dilip
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On