I was wondering if the following was possible with inline functions:
1. Can you include multiple functions in a single select statement
2. Can you include a combination of a Function and a query.
The answer is Yes to both Except that the functions must always be defined first. Otherwise, the compiler gets confused (understandably) starts throwing errors. I am on 12.1 version
with
function f1(p_id in number) return number is
begin
return p_id;
end;
function f2(p_id in number) return number is
begin
return p_id;
end;
qry1 as (select 12 nbr from dual),
qry2 as (select 'blah' data from dual)
select f1(id), f2(id), qry1.nbr, qry2.data
from t, qry1, qry2
where rownum < 3
;
This returns 2 rows (as expected)
1108 1108 12 blah
1109 1109 12 blah
However, if I try to put the query first followed by the function, I get all kinds of errors:
with
qry1 as (select 12 nbr from dual),
function f1(p_id in number) return number is
begin
return p_id;
end;
select f1(id), qry1.nbr
from t, qry1
where rownum < 3
;
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 8 Column: 11