Re: Copy the new row into another table... using Trigger
Date: 2000/08/07
Message-ID: <398E7305.1577_at_teleport.com>#1/1
Chris wrote:
>
> Hi, All
>
> How do I insert the new row (from NN, inserting) into another
> table(NNCopy) in the trigger tgr1 ?
>
> Create or replace trigger tgr1
> After insert on NN
> For each row
> begin
> insert into NNCopy
> ?????????????????????
> end;
>
> Table NN and NNCopy have the same table definition, there have about 30
> columns in NN.
>
> Thanks
>
> Chris Chi from Taiwan, R.O.C.
I don't know if it is the best way, but this should work:
CREATE OR REPLACE TRIGGER TGR1
AFTER INSERT ON NN
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
DECLARE
BEGIN
INSERT INTO NNCopy (col1,col2,col3,...)
VALUES (:NEW.col1,:NEW.col2,:NEW.col3,...);
EXCEPTION
WHEN OTHERS THEN
NULL;
END TGR1;
/
Yours,
Geoff Houck
systems hk
hksys_at_teleport.com
http://www.teleport.com/~hksys
Received on Mon Aug 07 2000 - 00:00:00 CEST