Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger with Multiple Inserts

Status
Not open for further replies.

Sethington

Technical User
May 16, 2006
34
US
I am creating a trigger for my database that will populate 6 tables with an ID. I know how to write the code I just can't seem to figure out how to make it my concise. Can anyone shoten this code for me please. Thanks

Code:
create or replace trigger WELL_ID_TRIGGER
after insert on WELLS
for each row
begin
                        
            insert into WELL_MAIN(WELL_ID),
            select :new.well_id from dual;
            
            insert into WELL_CONSTRUCTION(WELL_ID),
            select :new.well_id from dual;
            
            insert into WELL_GEOLOG(WELL_ID),
            select :new.well_id from dual;
            
            insert into WELL_LOCATION27(WELL_ID),
            select :new.well_id from dual;
            
            insert into WELL_LOCATION83(WELL_ID),
            select :new.well_id from dual;
            
            insert into WELL_ORIG_WATER_LEVEL(WELL_ID),
            select :new.well_id from dual;
              
end;
 
You do not need the references to DUAL
Code:
insert into WELL_MAIN(WELL_ID)         
values :new.well_id;
insert into WELL_CONSTRUCTION(WELL_ID) 
values :new.well_id;
insert into WELL_GEOLOG(WELL_ID)       
values :new.well_id;
insert into WELL_LOCATION27(WELL_ID)   
values :new.well_id;
insert into WELL_LOCATION83(WELL_ID)   
values :new.well_id;
insert into WELL_ORIG_WATER_LEVEL(WELL_ID)
values :new.well_id;


[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
do I have to say "insert into" 6 time or is there an easier way.
 
I do not know of a simpler way.

[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top