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

Hi any one plz help me .i need 2 or 3 customized and 2 or 3 development reports on PO module..if any body having plz send me with one by one step ,i mean where u do the customization and wht are the steps u follwed when u do the customization,wht are fields u added or deleted ,How u added or these fields as per clinet requirement and wht are errors u faced .plz send it to my mail id iamvenki@gmail.com

1888


What is a flexfield? List out its types.

663


What are the Standard Reports and Forms in HRMS?

1770


Hi  Friends this is preetham, i am  searching for job on oracle apps(technical) i put 3 years fake exp, so any one  please could you help me for realtime interview  questions and 9739782164 this is my no srpsrp777@gmail.Com please guys please provide your no for contact i have a doubts i want to clarify

1565


What are the different components you should consider while defining a responsibility in oracle apps?

639






How do you register report in oracle apps?

626


How to move the one file from one instance to another instance? And your scripts also?

615


In oracle application how do you debug or trace errors?

639


is it possible to run the interface without using oracle apps?

1516


How can you achieve loose coupling in soa framework?

717


do you know is it possible to run the interface without using oracle apps?

646


Can you differentiate between mediator and osb?

625


How can we import the data into a database using sql * loader?

678


How to create a purchase order without a requisition?

626


What do you understand by concurrent programs?

619