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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Using bind vars, ref cursors and dynamic SQL

Re: Using bind vars, ref cursors and dynamic SQL

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Wed, 02 Jul 2003 12:39:05 -0700
Message-ID: <3F0334D8.52EAD6EE@exxesolutions.com>


andrewst wrote:

> Originally posted by Daniel Morgan
> > Assuming 8i try this:
> >
> > CREATE OR REPLACE PROCEDURE child (
> > p_NumRecs IN PLS_INTEGER,
> > p_return_cur OUT uw_type.t_ref_cursor)
> > IS
> >
> > BEGIN
> > OPEN p_return_cur FOR
> > 'SELECT * FROM all_tables WHERE rownum <= ' || p_NumRecs ;
> >
> > END child;
> > /
> >
> > Assuming 9i try this:
> >
> > CREATE OR REPLACE PROCEDURE child (
> > p_NumRecs IN PLS_INTEGER,
> > p_return_cur OUT SYS_REFCURSOR)
> > IS
> >
> > BEGIN
> > OPEN p_return_cur FOR
> > 'SELECT * FROM all_tables WHERE rownum <= ' || p_NumRecs ;
> >
> > END child;
> > /
> >
> >
> Surely you meant to use bind variables?
>
> OPEN p_return_cur FOR
> 'SELECT * FROM all_tables WHERE rownum <= :n' USING p_NumRecs;
>
> --
> Posted via http://dbforums.com

Of course. Theses were just the simplest demos of returning REF CURSORs I could find.

--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Wed Jul 02 2003 - 14:39:05 CDT

Original text of this message

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