Example of creating temporary tables in PL/SQL like in MSSQL
For those who have switched from MSSQL to Oracle, like me, it's very uncomfortable to lack such a convenient construction as:
select * into #tmp from table1
Where #tmp - temporary table, with which we can further address within the session as with a normal one.
However, in Oracle this construction does not work. My attempts to find a similar analogue were unsuccessful. However, a miracle happened, and after some time, a more experienced colleague in this matter suggested a way out, which in essence implements a similar thing as in MSSQL.
So, here's how it turns out:
with
--Задаем временные таблицы
t_view1 as (select * from table1 where id = 1),
t_view2 as (select * from table2 where id = 1)
--Производим действия с использованием временных таблиц
select * from table3 t where
exists (select * from t_view1 v where v.id = t.id)
and exists (select * from t_view2 v where v.id = t.id)
And that's it!..
(A piece of code is not big and I think it's clear, without unnecessary explanation).
Comments (0)
No comments yet.