WHAT IS REFCURSOR IN ORACLE ?

Answer Posted / shaik jeelan basha

By using Ref cursor we can change the select statement
dynamically at runtime which is available in the cursor
definition based on some validation.For this we need to
define ref cursor type by using following syntax.

type <type_name> is ref cursor return <return_type>;

here <type_name> is the name of the ref cursor and
<return_type> will be the return type of ref cursor it may
be %type/%rowtype/record type/plsql table type/nested table
type/varray type.

if <return_type> is mentioned we will called it as strong
ref cursor.

if <return_type> is not mentioned we will called it as weak
ref cursor.

after this we need to define ref cursor variable by using
the following syntax.

v_variable_name ref_cursor_type_name;

then based on validations we can change the ref cursor
dynamically.

for example
------------------
declare
type ref_cur is ref cursor;
v_ref_cur ref_cur;
v_deptno emp.deptno%type;
begin
select deptno into v_deptno from emp where empno=7788;
if v_deptno=20 then
open v_ref_cur for select * from emp;
elsif v_deptno=30 then
open v_ref_cur for select * from dept;
else
open v_ref_cur for select * from salgrade;
end if;
end;

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is soa a part of oracle fusion middleware?

704


can we get profile values in report without using user exists is it possible how?

2405


What do you understand by soa?

780


What is count(*) from po_vendors(any table)?

729


List the various types of value set.

712






what is the difference between request group and request security in oracle apps?

5214


What are file in oracle.

1900


please any one provide the oracle erp technical interview questions on modules(PO,AP,AR,INV,GL,OM)wise to my mail id..narendra_609@yahoo.co.in

3191


how can develope the po variance and po summary report? with tables mandatory columns and query please?

2066


What are the different components of soa suite?

816


What are do's and dont's of Interface?

1992


where to define interorganization transaction charges and what are the different options?

2039


In hierarchical structure of a database? we have write query from where we should start?

1794


Which oracle applications pl/sql standard apis you are familiar, have you used most of them?

724


Can you differentiate between mediator and osb?

729