John C
John C

Reputation: 1835

Oracle trigger to update table with current row state

I have a table in Oracle with Timestamp field, a key field and 2 other columns. Am looking to create a trigger which would update another table with just the current state row data based on key, timestamp. Am new to trigger, any inputs and / or recommendation would be highly appreciated.

Upvotes: 0

Views: 177

Answers (1)

Piyush Mattoo
Piyush Mattoo

Reputation: 16123

create or replace TRIGGER A
AFTER INSERT
ON A1
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW

DECLARE
BEGIN

UPDATE C SET COLC=:new.colc, D=:new.cold, TIMESTAMP=:new.timestamp WHERE KEY=:new.key;

EXCEPTION
 WHEN OTHERS THEN
   -- Consider logging the error and then re-raise
   RAISE;
END A;

Upvotes: 1

Related Questions