Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1079
  • Last Modified:

Trigger for table in oracle

I have two tables
mytable with 'id' and 'message' as the columns and id as the primary key.
and fktable with 'id' and 'message' as the columns and id as the foreign key.

how can I create a trigger to 'mytable' so that the same value of the id field should be updated in the fktable's foreign key.



0
vinodkumarn37
Asked:
vinodkumarn37
1 Solution
 
vinodkumarn37Author Commented:
Can any one help me creating the trigger for the tables i posted
0
 
imran_fastCommented:

CREATE OR REPLACE TRIGGER OWNER.TRG_UPD_MSG AFTER UPDATE ON OWNER.MYTABLE FOR EACH ROW
BEGIN  
     
  IF :OLD.MESSAGE <> :NEW.MESSAGE THEN
    UPDATE OWNER.FKTABLE SET MESSAGE = :NEW.MESSAGE WHERE ID = :OLD.ID;
  END IF;
END;

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now