ORA-00907使用sql调用函数时

时间:2015-12-22 17:18:41

标签: sql oracle

尝试从返回自定义类型(表

)的函数中进行选择

我认为这会起作用

 select * from table(FW.CustomFunction ('value1','value2')) 

返回

  

ora-000902:数据类型无效

好的,所以我认为这样可行:

select * from table(cast  FW.CustomFunction ('value1','value2') AS CustomTypes.CustomTable  )

但我得到

  

ORA-00907:缺少右括号

我错过了什么线索? 模式定义如下:

CREATE OR REPLACE PACKAGE FW.CustomTypes IS
    TYPE CustomTable IS TABLE OF VARCHAR2(255 CHAR)
        INDEX BY BINARY_INTEGER;
END CustomTypes;
/

CREATE OR REPLACE FUNCTION FW.CustomFunction ( param1 IN VARCHAR2, param2 IN VARCHAR2 ) RETURN CustomTypes.CustomTable IS
    CustomTableToReturn CustomTypes.CustomTable;
BEGIN
    LOOP
        ...add items to CustomTableToReturn

    END LOOP; 

    RETURN CustomTableToReturn;
END;
/

1 个答案:

答案 0 :(得分:2)

施放的参数需要围绕它们的括号:

table(cast ( FW.CustomFunction ('value1','value2') AS CustomTypes.CustomTable ) )