Hi,

Your procedure has been partially modified. check if it will
do.

First crete a Object Type

SQL> create type empstr as object
2 (empid number(6),
3 age number(4));
4 /

Type created.


-- follwing is pl/sql block

declare
-- Create a type for above empstr object
Type p_emp_type is table of empstr ;

-- declare a variable on type and initilize.
p_emp_tab p_emp_type := p_emp_type(empstr(10,20));

cursor c1 is
select
emp_id, age
from
emp
where
emp_id in (888888, 3333);
exit_count number := 0;

-- extra variable added for counter in "for loop"
ctr number := 1;
BEGIN
dbms_output.put_line('Started : ');
for i in c1
loop
-- counter variable "ctr" is used here
p_emp_tab(ctr).emp_id := i.emp_id;
p_emp_tab(ctr).emp_id := i.age;
ctr := ctr + 1;
end loop;

dbms_output.put_line('finished loop : ');
loop
exit_count := exit_count + 1;
dbms_output.put_line('empid: ' ||p_emp_tab(exit_count).emp_id || ' age: ' || p_emp_tab(exit_count).age);

-- old condition was exit_count > 10
if exit_count >= ctr-1 then
exit;
end if;
end loop;
END;


run this procedure you will find output like this

Started :
finished loop :
empid: 10 age: 20

PL/SQL procedure successfully completed.



Thanks
P. Soni