Oracle SQL insert into with With clause
You may use as many 'helper_tables' as you wish.
create table t(helper1 varchar2(50) , helper2 varchar2(50) , dataElement varchar2(50) );
insert into t(helper1, helper2, dataelement)
with
de as(select level lvl from dual connect by level <10)
,h1 as (select lvl, lvl/1.5 hp from de)
,h2 as (select lvl, lvl/2 hp2 from de)
select h1.hp , h2.hp2, de.lvl
from de
inner join
h1 on de.lvl = h1.lvl
inner join
h2 on de.lvl = h2.lvl
/
With this in mind, you may be able to do all of your joins via normal joining of the tables to the master table
INSERT
INTO dummy1
WITH helper_table AS
(
SELECT *
FROM dummy2
)
SELECT t.a
FROM helper_table t
WHERE t.a = 'X'
You can do something like
INSERT INTO dummy1
WITH helper_table AS (
SELECT *
FROM dummy2
)
SELECT t.a
FROM helper_table t
WHERE t.a = 'X';
For your updated query
INSERT
INTO dummy values (a,b) //more values
WITH helper_table AS
(
SELECT *
FROM dummy2
),
helper_table2 AS //from more tables
(
SELECT *
FROM dummy3
)
SELECT t.value as a, t2.value as b
FROM helper_table t
join helper_table t2 on t.value = t2.value //some join
WHERE t.value = 'X' and t2.value = 'X' //other stuff