Link to home
Start Free TrialLog in
Avatar of Swaminathan K
Swaminathan KFlag for India

asked on

Error while using weak ref cursor in oracle 12c

Hi Team,

I have the below code in plsql for processing weak cursors , whenever i run  the code i get the below error. Any help is really appreciated. Iam using oracle 12c

ERROR at line 12:
ORA-06550: line 12, column 59:
PLS-00487: Invalid reference to variable 'L_EMPDEPTDATA'
ORA-06550: line 12, column 4:
PL/SQL: Statement ignored


declare
type t_empdeptdata is ref cursor;
l_empdeptdata t_empdeptdata ;
begin
open l_empdeptdata for
Select e.employee_id
from employees e
where e.department_id=30;
            begin
            loop
            exit when l_empdeptdata%NOTFOUND;
                  dbms_output.put_line ('Employee_id : '|| l_empdeptdata.employee_id );
            end loop;
            end;
            
      close l_empdeptdata;
end;
/
Avatar of Sean Stuber
Sean Stuber

you need to fetch the cursor into a variable that you can then dereference (or, if not a composite type, reference directly)
 or use a cursor for loop and dereference from the loop index
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Swaminathan K

ASKER

Thanks a lot . Awesome