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