I have one Oracle table say
Table1
(
roll_number,
myTimestamp
)
I have another Oracle table
Table2
(
roll_number,
myTimestamp,
recordid --> this is supposed to be an auto increment primary key
)
What I want is a trigger which inserts the record inserted into Table1 into Table2 as well but with the additional primary key integer column recordid being incremented and inserted automatically.
I am able to insert records without Table2 having this additional primary key column constraint using a trigger but when I try this additional column its giving issues.
I have tried creating an auto increment sequence (say MySeq) and tried to insert to create a trigger
create trigger MyTrigger
after insert on Table1
for each row
begin
insert into Table2 values ( :new.roll_number,:new.myTimestamp,select MySeq.nextval into :new.recordid from dual );
end;
but no luck. Thanks in advance
There's nothing wrong with it - at least, it works properly on my 11gXE (which database version do you use?):
Alternatively, instead of
VALUESuseSELECT: