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: Problem with cursor declaration

Re: Problem with cursor declaration

From: Kevin P. Fleming <kfleming_at_access-laserpress.com>
Date: Thu, 17 Sep 1998 20:13:06 GMT
Message-ID: <m3eM1.44400$435.21051104@news.rdc1.az.home.com>


You'll have to use the DBMS_SQL package to do what you want, which will be much more complicated, but it will work. You'll basically build the SELECT statement in a PL/SQL VARCHAR2 variable, pass it in to DBMS_SQL for parsing and execution, and then get a cursor variable for the results.

Paul Wagner wrote in message <6trpsf$17b$1_at_news1.tc.umn.edu>...
>I'm trying to set up a cursor within a PL/SQL procedure, where the cursor
>will allow me to select from a table name passed as a parameter to the
>procedure (PL/SQL 2.3, Oracle 7.3). I tried something like:
>
>declare
>...
> CURSOR pcursor (tablename VARCHAR2) IS
> SELECT * FROM tablename;
>...
>
>but I get errors saying the cursor is incomplete or malformed (PLS-00341)
>and that 'tablename' must name a table to which the user has access (PLS-
>00356).
>
>If I change "tablename" in the SELECT statement to the actual name of
>the table, it works fine. I'd thought, though, from the O'Reilly PL/SQL
>book, that you can use a cursor parameter anywhere in the select statement.
>Somehow it seems like the parameter name is being used instead of its
value.
>Any ideas on how to get this working or on any other way to have a cursor
>open a table which is specified in a string variable in the procedure?
>
>Thanks much for any and all help,
>
>Paul
>
>--
>* * * * * * * * * * * * * * *
*
>* Paul J. Wagner School - wagner_at_cs.umn.edu
*
>* Computer Science Department Work - wagnerp_at_uwstout.edu
*
>* University of Minnesota

*
>* * * * * * * * * * * * * * *
* Received on Thu Sep 17 1998 - 15:13:06 CDT

Original text of this message

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