Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can we declare a and use Cursor in package specification without body ?

User_1ZNO6Jun 1 2022 — edited Jun 1 2022

It's said in database pl sql language reference in topic 10.1 that 'If the public items include cursors or subprograms, then the package must also have a body.' .
I've tested cursor package spec without body and it worked fine (code below)

create or replace package some_pak is
 cursor c is select * from employees where employee_id <102;
end;

begin
 for i in some_pak.c
 loop
  dbms_output.put_line(i.employee_id|| ' '||i.first_name||' '|| i.salary);
 end loop;
end;
result :  
100 Steven 24000
101 Neena 17000

What i'm doing or understanding wrong?
p.s. Preparing for 1z0-149 exam and want to know accurate information.
Thank you!

Comments
Post Details
Added on Jun 1 2022
1 comment
381 views