With INSERT ... SELECT, you can quickly insert many rows into a table from the result of a SELECT statement, which can select from one or many tables. For example:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
Source: Oracle Docs
You can also insert record and set column values from multiple selects
insert into S_CON_EDU
(CON_ID,SCHOOL_ID,CLASS_GRADE,CREATED_BY,LAST_UPD_BY,DATE_DT,ROW_ID)
(select
(select con.row_id from s_contact con where con.IDN = '123654789'),
(select sch.row_id from S_ORG_EXT sch where sch.IDN like (select '%'||SUBSTR('1082AB', 1, 4)||'%' from dual)),
(select lov.name from S_LST_OF_VAL lov where lov.type = 'EDU_LEVEL' and lov.active_flg = 'Y' and lov.val = 'Grade Six' ),
'0-1',
'0-1',
SYSDATE,
'1-EDU101'
from dual)
Comments
Post a Comment