包含规范功能的Oracle 12c无法运行

时间:2017-05-12 21:27:43

标签: plsql oracle12c

我在包规范中有一个游标(涉及多个表连接)。我写它是因为我想要管道函数的返回类型。但是当我编译它时会给出以下错误。

[error] ora-00905 (4: 23): pl/sql: ora-00905: missing keyword
[error] pls-00103 (6: 15): pls-00103: encountered the symbol "BEGIN" when expecting one of the following:

   end function pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor d
[error] pls-00103 (25: 14): pls-00103: encountered the symbol "S" when expecting one of the following:
end not pragma final instantiable order overriding static
member constructor map.

我可以将光标移动到正文中吗?但我需要管道功能的返回类型

以下是示例包:

CREATE OR REPLACE PACKAGE pkg_test AS
   CURSOR cur_match IS
        WITH FUNCTION Fun(p_id varchar2) RETURN varchar2 IS
            v_desc VARCHAR2(100);
              BEGIN
                  v_desc := CASE p_id WHEN NULL THEN '123' WHEN 'A' THEN '345' WHEN 'B' THEN '678' 
                            END; 
                RETURN v_desc;   
              END;
             s AS (SELECT sysdate FROM dual)
      SELECT s.*,Fun('X') FROM s;
      TYPE tab_cur IS TABLE OF cur_match%ROWTYPE;

    FUNCTION get_data RETURN tab_cur PIPELINED;
  END;

1 个答案:

答案 0 :(得分:2)

根据这个:

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

WITH FUNCTION没有PLSQL支持,即不能在PLSQL块中使用。

也许您可以尝试使用该查询创建一个VIEW,并引用PLSQL块中的视图。