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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor variables again 1

Status
Not open for further replies.

suggs

Programmer
May 15, 2001
10
0
0
DE
Right what i've got is a situation where I need to pass the table name to a procedure and open the cursor variable in the procedure with the variablr table name ptable when i try to compile this i get the error
Errors for PACKAGE BODY CURSOR_WEAK:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/3 PL/SQL: Statement ignored
5/21 PLS-00201: identifier 'MY_CUR' must be declared
10/19 PL/SQL: SQL Statement ignored
10/33 PLS-00201: identifier 'PTABLE' must be declared

can I not use variables that I have declared in the spec to use in the select statement.


create or replace package cursor_weak as
type my_cursor is REF CURSOR;
procedure open_cursor_data (my_cur in out my_cursor, ptable VARCHAR2);
procedure get_table_data;
end;
/

create or replace package body cursor_weak as

procedure get_table_data is
begin
open_cursor_data (my_cur, 'data1');
end;

procedure open_cursor_data (my_cur in out my_cursor, ptable VARCHAR2) is
begin
open my_cur FOR SELECT * FROM ptable;
end;

end;
/
 
my_cur is beyond of scope in get_table_data. It must be either "global" for package or passed as a parameter.
 
Hiya sem I really don't know what you mean I've only started using pl/sql in the last few weeks and this cursor variable stuff is doing my head in could you expand a bit and maybe give me an exaple i would really appreciate it
 
It means, that your get_table_data can not "see" my_cur variable untill it's defined in package (in spec or body, but not within procedure) or declared as a parameter (as in your open_cursor_data procedure). My_cur is "private" for open_cursor_data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top