Dear All,
I have created one normal cursor and another oneis ref cursor when i tried to run the below Noraml cursor and ref cursor datatype, we are getting same result set. Can you please tell me what is major diffrence both of them.
-- Normal Cursor
declare
cursor emp_c is select * from employees;
v_emp employees%rowtype;
begin
open emp_c;
loop
fetch emp_c into v_emp;
dbms_output.put_line(v_emp.employee_id||' '||v_emp.last_name||' '||v_emp.first_name);
exit
when emp_c%notfound;
end loop;
close emp_c;
end;
-- Using refcursor
declare
type cus is ref cursor;
cus1 cus;
emp_ro employees%rowtype;
begin
open cus1 for select * from employees;
loop
fetch cus1 into emp_ro;
dbms_output.put_line(emp_ro.employee_id||' '||emp_ro.last_name||' '||emp_ro.first_name);
exit
when cus1%notfound;
end loop;
close cus1;
end;
Thanks.