PL/SQL print out ref cursor returned by a stored procedure

后端 未结 3 1329
谎友^
谎友^ 2020-12-01 06:27

How can I fetch from a ref cursor that is returned from a stored procedure (OUT variable) and print the resulting rows to STDOUT in SQL*PLUS?

ORACLE stored procedure

3条回答
  •  没有蜡笔的小新
    2020-12-01 07:01

    If you want to print all the columns in your select clause you can go with the autoprint command.

    CREATE OR REPLACE PROCEDURE sps_detail_dtest(v_refcur OUT sys_refcursor)
    AS
    BEGIN
      OPEN v_refcur FOR 'select * from dummy_table';
    END;
    
    SET autoprint on;
    
    --calling the procedure
    VAR vcur refcursor;
    DECLARE 
    BEGIN
      sps_detail_dtest(vrefcur=>:vcur);
    END;
    

    Hope this gives you an alternate solution

提交回复
热议问题