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: andrewst <member14183_at_dbforums.com>
Date: Wed, 02 Jul 2003 17:23:41 +0000
Message-ID: <3067714.1057166621@dbforums.com>

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
Received on Wed Jul 02 2003 - 12:23:41 CDT

Original text of this message

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