Hi All,
I’m trying to populate a column on one table with the primary key from a column on another table that is automatically created when a new row is added.
TABLE_1 automatically generates a primary key called PROJECT_ID when a new row is created. I’ve built a trigger to insert data from TABLE_3 into TABLE_2 when a new row is created on TABLE_1. TABLE_2 also has a column called PROJECT_ID and when the data from TABLE_3 populates TABLE_2, I want the PROJECT_ID on TABLE_2 to match the PROJECT_ID from the newly created row on TABLE_1.
I’m trying to do this with 2 insert into statements but only the first one seems to work. Any advice on how to do this? Thanks!
Here is my code:
create or replace trigger "Trigger_T1"
BEFORE
insert on "TABLE_1"
for each row
begin
insert into TABLE_2
(MILESTONE_DESCRIPTION)
select MILESTONE
from TABLE_3;
insert into TABLE_2
(PROJECT_ID)
select PROJECt_ID
from TABLE_1;
end;