Home » SQL & PL/SQL » SQL & PL/SQL » OUTPUT Of SYS_REFCURSOR (oracle 11g Release 2)
OUTPUT Of SYS_REFCURSOR [message #628659] Wed, 26 November 2014 15:28 Go to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
hi,

was trying to execute this procedure , not able the see the output ,
i have set dbms_output ON also, it works runs successfully,
gives error on dbms-utput in this code,
aim is to see the output of this execution result.
SET SERVEROUTPUT ON
DECLARE 
  P_CUST_ID VARCHAR2(32);
  P_INPT_CD VARCHAR2(2);
  P_PROD_CD VARCHAR2(20);
  P_RLSED_DT DATE;
  P_FIRST_IN VARCHAR2(32767);
  P_EXCL_TBL_IN VARCHAR2(32767);
  P_HIST_DATE DATE;
  P_CURSOR SYS_REFCURSOR;

BEGIN 
  P_CUST_ID := NULL;
  P_INPT_CD := NULL;
  P_PROD_CD := NULL;
  P_RLSED_DT := NULL;
  P_FIRST_IN := NULL;
  P_EXCL_TBL_IN := NULL;
  P_HIST_DATE := NULL;
  -- P_CURSOR := NULL;  Modify the code to initialize this parameter

  PKG_SEARCH.SEARCH_TXNS('', 'A', 'RETURNS', '10-NOV-2014','R', 'F', '09-NOV-2014', P_CURSOR );
  --DBMS_OUTPUT.PUT_LINE(' V_RETURN = '  || '  ' ||  P_CURSOR);
  COMMIT; 
END; 
/


any idea how can i see the output, i have tried in SQL Developer, SQL Plus and Toad, all same.
shows this PL/SQL procedure successfully completed.
but no output.
Re: OUTPUT Of SYS_REFCURSOR [message #628661 is a reply to message #628659] Wed, 26 November 2014 15:35 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
In SQL*PLus:

VARIABLE CUR REFCURSOR
BEGIN 
    PKG_SEARCH.SEARCH_TXNS('','A','RETURNS',DATE '2014-11-10','R','F',DATE '2014-11-09',:CUR);
END; 
/
PRINT CUR


SY.
Re: OUTPUT Of SYS_REFCURSOR [message #628663 is a reply to message #628661] Wed, 26 November 2014 15:56 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
To be clear on why your attempt didn't work - you opened the ref cursor but you didn't fetch from it. The sqlplus print command does that for you. Otherwise you need to write a loop that'll fetch the results (with the fetch command) into appropriate variables. You can then display the contents of those variables.
All that said - just use the print command.
icon14.gif  Re: OUTPUT Of SYS_REFCURSOR [message #628664 is a reply to message #628661] Wed, 26 November 2014 16:32 Go to previous message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
Thank You.
Previous Topic: Fulfill the width with different combination
Next Topic: creating view based on availability of data in 2 tables
Goto Forum:
  


Current Time: Thu Apr 25 03:59:06 CDT 2024