How to display a sys_refcursor data in TOAD's DataGrid

前端 未结 2 705
我寻月下人不归
我寻月下人不归 2021-02-04 13:11

Please i need help. (I SEARCHED A lot and get more confused . )

I use Toad 9.7.25 and i made this procedure (in a package)

PROCEDURE ReportaCC(pfcorte I         


        
相关标签:
2条回答
  • 2021-02-04 13:40

    After you hit F9 the "Variables" dialog appears and you select Type=Cursor from the dropdown list then press OK:

    Select Type=Cursor

    The reason you are getting the "ORA-24338: statement handle not executed" error is because you are closing your cursor before it is accessed.

    This is the process that is happening:

    1. Execute procedure
    2. OPEN statement returns a pointer to the result set in memory (but does not return any data)
    3. CLOSE statement discards the results before they are accessed
    4. Procedure call ends
    5. The client caller (in this case TOAD) attempts to access the result stream, but the pointer is invalid, so nothing can be read and the error is thrown

    Solution: Remove the close lcursor; statement.

    0 讨论(0)
  • 2021-02-04 13:48

    As your procedure is doing only a select statement better use a function like

    CREATE or REPLACE function ReportaCC(pfcorte IN DATE) 
    RETURN SYS_REFCURSOR
    AS
       lcursor   SYS_REFCURSOR;
    BEGIN
       OPEN lcursor FOR
         select c1, c3, c3 from table1 where hdate = pfcorte;
       RETURN lcursor ;
    END;
    /
    

    Do not close lcursor here, close from your calling statement because if you close lcursor then you wouldn't be able to see any results.

    And execute as

    select ReportaCC(<>) from dual
    

    from toad, double click cursor in datagrid to see the results.

    0 讨论(0)
提交回复
热议问题