Skip to Main Content

INSERTING and DELETING ROWs to another table using Triggers

user10903866Jun 16 2014 — edited Jun 16 2014

Hi Everyone,

I am using ORACLE 11G on Enterprise Linux 5.

I am trying to insert, update or delete rows from one table to another table using AFTER INSERT, UPDATE OR DELETE triggers. Is it possible to insert, update or delete data ( from TABLE A ) to TABLE B whenever a change ( insert update or delete ) happens in TABLE A. The aim here is to replicate changes to another database which is available through DBLINK.

CREATE OR REPLACE TRIGGER PERSONNEL_TRIGGER

AFTER INSERT OR UPDATE OR DELETE  ON PERSONNEL

FOR EACH ROW

BEGIN

  CASE

    WHEN INSERTING THEN

      INSERT INTO PERSONNEL@REMOTE ( employeeid,firstname,lastname,email)

      VALUE ( HOW CAN I GRAB VALUES FOR THE NEWLY INSERTED ROW/S' )

    WHEN UPDATING THEN

      UPDATE PERSONNEL@REMOTE SET firstname = '?????', lastname ='????', email = '????' where employeid = 'UPDATED ROW ID'

    WHEN DELETING THEN

      DELETE FROM PERSONNEL@REMOTE where employeeid = 'ID OF THE RECORD DELETED from PERSONNEL TABLE'

  END CASE

END;

Can any one help me how to grab the inserted row data, updated row data or deleted row data so that I can push that from the trigger

Comments
Post Details
Added on Jun 16 2014
4 comments
2,822 views