Hi All,
I have three tables (TABLE_1, TABLE_2, & TABLE_3). I have a trigger on TABLE_1 that, when fired, inserts data from one column in TABLE_3 into TABLE_2. This trigger is fired when a new record is created on TABLE_1. This results in new records being added on TABLE_2 (3 to be exact). Additionally, when a new record is created on TABLE_1, a primary key (called PROJECT_ID) is automatically generated for the new record on TABLE_1.
Now what I need to do is create a trigger that will insert the primary key (PROJECT_ID) from the new record created on TABLE_1 to each of the new records created on TABLE_2 in the corresponding PROJECT_ID column when the first trigger is fired. The new records on TABLE_2 should all have the same PROJECT_ID matching the one created in TABLE_1.
Any help with the SQL code on this would be very helpful and also advice on what table the 2nd trigger should be added to.
Here is the code for the first trigger. What can I add to make that PROJECT_ID column on TABLE_2 populate with the PROJECT_ID from TABLE_1?
create or replace trigger "TABLE_1_TRIGGER"
BEFORE
insert on "TABLE_1"
begin
insert into TABLE_2
(MILESTONE)
select MILESTONE
from TABLE_3;
end;