-1
我想在一個簡單的例子中應用表(函數)功能。我用從過程的SELECT,表(功能)方法時,收到以下錯誤WHERE語句Oracle PL/SQL:表(函數)錯誤
Error: PLS-00231: function 'GET_NUM' may not be used in SQL
對什麼是錯在這段代碼的任何見解。
CREATE OR REPLACE PACKAGE BODY TEST IS
--COLLECTION DELCARATION
TYPE num_list IS TABLE OF NUMBER;
TYPE str_list IS TABLE OF NUMBER;
FUNCTION get_num(id IN NUMBER)
RETURN num_list AS
num num_list;
BEGIN
WITH xTable AS
(
SELECT 1 ID, 111 NUM, 'ABC 111' DESCP FROM DUAL
UNION ALL
SELECT 2 ID, 222 NUM, 'ABC 222' DESCP FROM DUAL
UNION ALL
SELECT 1 ID, 333 NUM, 'ABC 333' DESCP FROM DUAL
)
SELECT x.NUM
BULK COLLECT INTO num
FROM xTable x
WHERE x.ID = id;
RETURN num;
END;
PROCEDURE insert_object_id_control AS
i NUMBER:= 1;
str str_list;
BEGIN
WITH yTable AS
(
SELECT 1 ID, 111 NUM, 'ABC 111' DESCP FROM DUAL
UNION ALL
SELECT 2 ID, 222 NUM, 'ABC 222' DESCP FROM DUAL
UNION ALL
SELECT 3 ID, 333 NUM, 'ABC 333' DESCP FROM DUAL
)
SELECT y.DESCP
INTO str /*BULL COLLECT INTO GET'S SAME RESULT*/
FROM yTable y
WHERE y.NUM IN (SELECT * FROM TABLE(get_num(i)));
END insert_object_id_control;
END TEST;
在此過程中'insert_object_id_control'你沒有INTO運行選擇。這不能編譯。如果您的軟件包已編譯,代碼與您發佈的代碼不同 – Aleksej
是不是同一個問題http://stackoverflow.com/questions/41680033/oracle-pl-sql-function-cursor/41695029?noredirect=1#評論70587650_41695029 ...我已經在這裏提到過它不會起作用,但是如果你不接受任何東西,你就會接受錯誤的答案。 – XING
此外,你甚至沒有按照提到那裏'select * from table(get_num(1))'應該從表中選擇column_value(get_num(1))' – XING