Skip to Main Content

old and new in trigger

user543623Dec 24 2011 — edited Dec 26 2011
1. Table A1 and table A2 has same two columns:
(ID, Name)

Select * from a2
One row returned as :
Id = 1 name = a

2. create or replace trigger a1a2
before insert
on a1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE

begin

insert into a2
values(:old.ID, :old.NAMF);

insert into a2
values(:new.ID, :new.NAMF);

End ;
/

3. insert into a1 values(2, ‘b’)
4. select * from A2
3 rows returned as :
First row------1 a
2nd row-------
3rd row-------2 b

5. why 2nd row is empty???
6. I was expecting as :
First row------1 a
2nd row------- 1 a
3rd row-------2 b


Some one pls explain me how the old and new values work?

Thanks.
Comments
Post Details
Added on Dec 24 2011
3 comments
3,447 views