Skip to Main Content

SQL Developer Data Modeler

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

after update trigger with condition

user2040934Dec 29 2012 — edited Dec 31 2012
Dear members,

I have a table with multiple columns on each update on these columns I have to update another table columns.

for one column the following trigger is working fine, but there are about more than 10 columns which I have to check for.

I want to create only one after update trigger on this table and check which column is updated and update the same column in 2nd table.

here is the trigger:
CREATE OR REPLACE TRIGGER ABC_RATE_UPD
AFTER UPDATE
   OF RATE
   ON ABC_PCD  
   REFERENCING NEW AS New OLD AS Old
   FOR EACH ROW
DECLARE
  BEGIN

    UPDATE RM_TRAN_IN
    SET RATE = :NEW.RATE
    WHERE RM_PCD_ID = :NEW.RM_PCD_ID;
   EXCEPTION
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END ABC_RATE_UPD;
here is my if condition, (edited)

if :NEW.RATE != :OLD.RATE then
    
        UPDATE ABC_TRAN_IN
        SET RATE = :NEW.RATE
        WHERE ABC_PCD_ID = :NEW.ABC_PCD_ID;

    ELSIF :NEW.PACK_UNIT_ID != :OLD.PACK_UNIT_ID then
    
        UPDATE ABC_TRAN_IN
        SET PACK_UNIT_ID = :NEW.PACK_UNIT_ID
        WHERE ABC_PCD_ID = :NEW.ABC_PCD_ID;
END IF;
    
Its working good, is this a good approach, to the solution?

regards:

Edited by: user2040934 on Dec 29, 2012 3:22 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2013
Added on Dec 29 2012
5 comments
36,700 views