Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Problem with cursor declaration
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
--
* * * * * * * * * * * * * * * *