Why doesn't the below code compile:
DECLARE
c number;
BEGIN
WITH
FUNCTION calculate(i IN NUMBER) RETURN NUMBER
AS
r number;
BEGIN
r := i*i;
RETURN r;
END;
select calculate(1) INTO c from dual;
END;
giving the following error:
Error report -
*ORA-06550: line 5, column 10:
PL/SQL: ORA-00905: missing keyword
ORA-06550: line 4, column 1:
PL/SQL: SQL Statement ignored
whereas:
WITH
FUNCTION calculate(i IN NUMBER) RETURN NUMBER
AS
r number;
BEGIN
r := i*i;
RETURN r;
END;
select calculate(1) from dual;
compiles?
Oracle version information
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
select into
isn't quite the same asselect
. It's possible thewith function ...
syntax hasn't made it into the PL/SQL version yet; although as the syntax diagrams don't even show the CTE syntax it's hard to tell. Are you using 12cR1 or 12cR2 - it might have changed between releases? – Alex Poole