Q. What is Ref Cursor?

A. A ref cursor is a variable, defined as a cursor type, which will point to a cursor result. The advantage that a ref cursor has over a plain cursor is that is can be passed as a variable to a procedure or a function.
Ref Cursors are of 2 types: Weak and Strong. In the case of Strong type, the data type of the returned cursor result is defined whereas in Weak type, it is not defined.

Eg:type erp_cursor is ref cursor; -- weak
type erp_cursor is ref cursor returning erp%rowtype; --strong

declare
2 type erp_cursor is ref cursor;
3 c1 erp_cursor;
4 r_c1 articles%rowtype;
5 r2_c1 scripts%rowtype;
6
7 begin
8 open c1 for select * from articles;
9 fetch c1 into r_c1;
10 close c1;
11 open c1 for select * from scripts;
12 fetch c1 into r2_c1;
13 close c1;
14 end;