我有一个包体,如下所示。我需要在函数体内调用一个名为TESTING()的函数并调用另一个查询。代码如下:
CREATE OR REPLACE PACKAGE BODY TEST_PCAKAGE AS -- body
FUNCTION OUTER_FUNCTION (
INPUT_A IN VARCHAR2,
INPUT_B IN DATE,
) RETURN REF_CURSOR_TYPE IS
CUR_CA_RECEIPTS REF_CURSOR_TYPE;
BEGIN
OPEN CUR_CA_RECEIPTS FOR
TESTING();
SELECT * FROM TEST_TABLE;
RETURN CUR_CA_RECEIPTS;
END OUTER_FUNCTION;
END TEST_PCAKAGE ;
创建此包体时,它会给我错误。谁能告诉我怎么做?
错误:错误(14,1):PLS-00428:此SELECT语句中需要INTO子句
create or replace
FUNCTION "TESTING" RETURN VARCHAR2
AS
BEGIN
RETURN('SUCCESS');
END;
答案 0 :(得分:0)
我猜你试图从函数
返回光标试试这个:
CREATE OR REPLACE PACKAGE BODY TEST_PCAKAGE AS -- body
FUNCTION OUTER_FUNCTION (
INPUT_A IN VARCHAR2,
INPUT_B IN DATE,
) RETURN REF_CURSOR_TYPE IS
-- use sys_refcursor for dynamic cursors
CUR_CA_RECEIPTS sys_refcursor;
BEGIN
-- Open the cursor for a query and not a function
OPEN CUR_CA_RECEIPTS FOR SELECT * FROM TEST_TABLE;
-- i'm guessing this is for debug
TESTING();
-- you can now iterate it in a different procedure
RETURN CUR_CA_RECEIPTS;
END OUTER_FUNCTION;
END TEST_PCAKAGE ;