Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Ref Cursor

Re: Ref Cursor

From: Richard Kuhler <noone_at_nowhere.com>
Date: Fri, 20 Feb 2004 20:13:15 GMT
Message-ID: <vTtZb.10375$Le2.8839@twister.socal.rr.com>


Alex wrote:
> I'm trying to execute a dynamic SQL statement using a ref cursor
> variable. The following is a simple example of what I'm trying to
> accomplish. I'd like to know how to declare the variable v_cur_dat to
> be able to accept any output, not only from table emp? Thanks in
> advance for your help.
>
> Alex
>
>
> DECLARE
>
> TYPE ref_cur_type IS REF CURSOR;
> v_cur ref_cur_type;
>
> v_cur_dat ??????
>
> BEGIN
> OPEN v_cur FOR SELECT * FROM emp;
>
> FETCH v_cur INTO v_cur_dat;
>
> END;
XML is one of several solutions (ANYDATASET and DBMS_SQL also come to mind). There are many function to extract data from the xmltype.

declare

     refcur sys_refcursor;
     xml xmltype;

begin

     open refcur for '
         select xmlforest(table_name, tablespace_name, num_rows)
         from user_tables';

     loop

         fetch refcur into xml;
         exit when refcur%notfound;

         dbms_output.put_line(xml.getstringval());

     end loop;

end;
/

--
Richard Kuhler
Received on Fri Feb 20 2004 - 14:13:15 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US