Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a cursor which the table name is dynamic

Status
Not open for further replies.

comgrit

MIS
Dec 24, 2002
22
TH
Hi,

I'm trying to create a cursor within a procedure that have a tablename as parameter. This example is showing what I intend to do:

create or replace procedure test (p1 varchar2) as
cursor c1 (tabname IN varchar2)
is select distinct prod_code from tabname;
c1_rec c1%ROWTYPE;
begin
open c1(p1);
loop
fetch c1 into c1_rec;
dbms_output.put_line(c1_rec.prod_code);
end loop;
close c1;
end;

However, I could not compile the procedure encounter error : PL/SQL: ORA-00942: table or view does not exist

How to overcome this issue ? Thanks in advance.

-------------------------------------
Comgrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top