Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Triggers and sequences
I am developing a system which will in essence perform the folowing task.
Insert rows into a master table and insert rows into a child table.
The master table rows will have a primary key based upon a sequence. The primary key column will be filled in using a TRIGGER.
i.e.:
create OR REPLACE trigger master_table_record_insert
before insert
on master_table for each row
begin
select master_sequence.nextval into :new.code from sys.dual;
end;
This is the master table.
There will be a child table which has a dual column primary key.
Column one is the primary key value from the corresponding row
in the master table.
Column two is based upon another sequence.
They are updated in the same transaction.
therefore I am able to do ...
create OR REPLACE trigger child_table_record_insert
before insert
on child_table for each row
begin
select master_sequence.currval into :new.master_code from sys.dual;
select child_sequence.nextval into :new.child_code from sys.dual;
end;
My two concerns are..
Any help will be greatly appreciated. Received on Thu Aug 19 1999 - 04:58:42 CDT