I am trying to insert into multiple tables, but the same subselect should be used in the insert stataments. When I am using With Clause, it does not work
This is working
INSERT INTO TABLE_A (COL_1, COL2)
SELECT COL_1, COL_2
FROM TABLE_A
JOIN ...
WHERE ...
This subselect should be used in other insert statements too..
SELECT COL_1, COL_2
FROM TABLE_A
JOIN ...
WHERE ...
Try to solve it so but does not work, for the first insert
WITH TEMP AS (
SELECT COL_1, COL_2
FROM TABLE_A
JOIN ...
WHERE ...);
INSERT INTO TABLE_A (COL_1, COL2)
SELECT COL_1, COL_2
FROM TEMP
How can I do this to use the same subselect for whole my insert statements?