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;
/
* Oracle12c* Oracle PL/SQLOracle Database

Avatar of undefined
Last Comment
Swaminathan K
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Swaminathan K

ASKER

Thanks a lot . Awesome
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo