I have SELECT
like
SELECT t1.A,
t2.A,
t1.B,
t2.B,
case when v_val2 < sysdate
then null
else t2.D
end
from t1
left join t2
on t1.C = t2.C and t2.D = p_val1
where t2.ref_date = p_val2
Where p_val1 and p_val2 are params. The real SELECT
is more complex and join tables with 140 million rows or more.
How can I reuse this select on more than one place? Now I use it in Business Object Report, VIEW, Insert and spool file. I tried to create VIEW but without params it is too slow.
I searched for something like view with parameter, but in this theme in Ask TOM а conclusion is that there isn't such thing.
UPDATE
p_val1 can be 4 fix values(like 'A','B','C','D'), but p_val2 is more complex because it is load date(date when the data was loaded). There is around 500 history load date and after that loading become daily. Every report, output and so on must be get by date.