Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Why doesn't the function in the with clause does not work in 12.1?

PLSQL_GUYMar 27 2017 — edited Mar 28 2017

Why doesn't the function in the with clause does not work in 12.1?

https://oracle-base.com/articles/12c/with-clause-enhancements-12cr1#functions

SQL> SELECT * FROM V$VERSION;

BANNER                                                                               CON_ID

-------------------------------------------------------------------------------- ----------

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production              0

PL/SQL Release 12.1.0.2.0 - Production                                                    0

CORE 12.1.0.2.0 Production                                                                0

TNS for Solaris: Version 12.1.0.2.0 - Production                                          0

NLSRTL Version 12.1.0.2.0 - Production                                                    0

SQL>

SQL> DECLARE

  2    v_1 NUMBER;

  3  BEGIN

  4 

  5    WITH

  6      FUNCTION with_function(p_id IN NUMBER) RETURN NUMBER IS

  7      BEGIN

  8        RETURN p_id;

  9      END;

10    SELECT with_function(id)

11    INTO v_1

12    FROM   t1

13    WHERE  rownum = 1;

14 

15    DBMS_OUTPUT.PUT_LINE(V_1);

16 

17  END;

18  /

DECLARE

  v_1 NUMBER;

BEGIN

  WITH

    FUNCTION with_function(p_id IN NUMBER) RETURN NUMBER IS

    BEGIN

      RETURN p_id;

    END;

  SELECT with_function(id)

  INTO v_1

  FROM   t1

  WHERE  rownum = 1;

  DBMS_OUTPUT.PUT_LINE(V_1);

END;

ORA-06550: line 6, column 14:

PL/SQL: ORA-00905: missing keyword

ORA-06550: line 5, column 3:

PL/SQL: SQL Statement ignored

ORA-06550: line 10, column 3:

PLS-00103: Encountered the symbol "SELECT"

This post has been answered by Tércio Costa on Mar 28 2017
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 25 2017
Added on Mar 27 2017
28 comments
3,209 views