This appears to be a client issue, which environment are you running these in?
For example, in SQL*Plus the subquery works fine:
SQL> select /*+ WITH_PLSQL */ calc from
2 (
3 with
4 function calculator (m number, r number) return number
5 is begin
6 return m * r;
7 end calculator;
8 select calculator(3, 2) as calc from dual
9 );
10 /
CALC
----------
6
But in SQL Developer:
select /*+ WITH_PLSQL */ calc from
(
with
function calculator (m number, r number) return number
is begin
return m * r;
end calculator;
select calculator(3, 2) as calc from dual
);
/
Error starting at line : 23 in command -
select /*+ WITH_PLSQL */ calc from
(
with
function calculator (m number, r number) return number
is begin
return m * r
Error at Command Line : 26 Column : 1
Error report -
SQL Error: ORA-06553: PLS-103: Encountered the symbol "end-of-file" when expecting one of the following:
When creating the view, remove the outer parenthesis and you'll be fine in SQL*Plus:
SQL> create or replace view abc as
2 with function calculator (m number, r number) return number is begin
3 return m * r;
4 end calculator;
5 select calculator(3, 2) as calc from dual;
6 /
View created.
SQL> select * from abc;
CALC
----------
6