简体   繁体   中英

Oracle 12c function in the WITH clause of subquery

I have a problem with subquery in the WITH clause.

Oracle version: 12c Enterprise Edition Release 12.1.0.2.0 - 64b

WITH
  FUNCTION upper_string(p_string IN VARCHAR2) RETURN VARCHAR2
  IS
  BEGIN
    RETURN UPPER(p_string);
  END;
SELECT upper_string AS ret_val
FROM dual;  

I am getting

PLS-103: Encoutered the symbol "end-of-file"...

Any guess where is the problem?

Thanks in advance!

Here you can find some infos about enhancements for WITH clause. You may try to use:

WITH
  FUNCTION upper_string(p_string IN VARCHAR2) RETURN VARCHAR2
  IS
  BEGIN
    RETURN UPPER(p_string);
  END;
SELECT upper_string AS ret_val
FROM dual
/

In your select you do not pass parameter to the function.

 SELECT upper_string('something to upper') AS ret_val
   FROM dual; 

But the error probably states that you are in old environment, that does not support syntax of 12c.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM