0

我在同一个包中有 2 个程序。我希望 QOT_LST_M_QOT_PREQOT_LST_M_SEC_EXC_PRE. 在 QOT_LST_M_SEC_EXC_PREI 中希望找到参数 - x_qot_id,使用此参数调用 QOT_LST_M_QOT_PRE 并返回它而不是语句。我可以做吗?如何。我的意思是

    PROCEDURE QOT_LST_M_SEC_EXC_PRE (
        i_sec_id     IN NUMBER,
        i_exc_id     IN NUMBER,
        o_recordset  OUT SYS_REFCURSOR ) IS x_qot_id NUMBER(10); 
        ------------------------------   
    BEGIN

    ---------------------------------------------------------------

    --call a function instead of writing query from this function
    open o_recordset for QOT_LST_M_QOT_PRE(x_qot_id, o_recordset);
    ----------------------------------------------------------------

    END  QOT_LST_M_SEC_EXC_PRE;





     PROCEDURE QOT_LST_M_QOT_PRE
    (
        i_qot_id     IN NUMBER,            
        o_recordset  OUT SYS_REFCURSOR
        --------------------------------
    );
4

1 回答 1

0

你当然可以。您可以声明 out 类型的参数SYS_REFCURSOR并在您的过程中使用它们,这是一个示例:

CREATE OR REPLACE PROCEDURE QOT_LST_M_QOT_PRE (i_qot_id IN NUMBER, THE_CURSOR OUT SYS_REFCURSOR) --Declare a sys_refcursor to be an out parameter, so it can be used outside
AS
BEGIN
 OPEN THE_CURSOR FOR SELECT * FROM THE_TABLE WHERE X=i_qot_id;--Open the cursor
END;

CREATE OR REPLACE PROCEDURE QOT_LST_M_SEC_EXC_PRE (i_sec_id IN NUMBER, i_exc_id IN NUMBER)
AS
x_qot_id NUMBER(10); --Test param
RESULT_CURSOR SYS_REFCURSOR;--The cursor that will hold the opened cursor in QOT_LST_M_QOT_PRE procedure
SOMEVARIABLE VARCHAR2(10);--Test variables to hold results of cursor
BEGIN
 QOT_LST_M_QOT_PRE(1,RESULT_CURSOR);--Procedure will open RESULT_CURSOR
 LOOP --Loop cursor
    FETCH RESULT_CURSOR INTO SOMEVARIABLE;
    EXIT WHEN RESULT_CURSOR%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE('READ :'||SOMEVARIABLE);
 END LOOP;
 CLOSE RESULT_CURSOR;--Close the opened cursor
END;
于 2013-09-13T16:48:48.530 回答