what is ref cursor in pl/sql?
Answers were Sorted based on User's Feedback
Answer / hitendra yadav
Reference cursor is as like pointer in C ad PASCAL language
which is point the data's memory location,REF CURSOR is
dynamic cursor which can be open for more then one query.
there are two type of ref cursof:-
(1) WEEK REF CURSOR:- ref cursor which not have return
cluse in defination.
(2) STRONG REF CURSOR :- ref cursor which use return cluse
in defination.
for example:-
SET serveroutput ON
DECLAR
TYPE eref REF CURSOR; -- WEEK REF CURSOR
eref1 eref;
erec employees%ROWTYPE;
BEGIN
OPEN eref1 FOR SELECT *
FROM employees
WHERE dept_id=90;
LOOP
FETCH eref1
INTO erec;
DBMS_OUTPUT.PUT_LINE(erec.emp_id);
EXIT WHEN eref1%NOTFOUND;
END LOOP;
END;
| Is This Answer Correct ? | 30 Yes | 4 No |
Answer / swapna
A Reference Cursor is majorly used when we want to execute
a dynamic select statement causes to retrieve more than
one record. We can pass Reference cursor result as a out
parameter which can be used in other sub programs.
| Is This Answer Correct ? | 27 Yes | 7 No |
Answer / suresh kumar somayajula
Re-usability of a cursor is nothing but " REF CURSOR".
It is of 2 types.
1. Weak REF Cursor
2. Strong REF Cursor.
SYNTAX:
1.Strong Refcursor
SYN: TYPE <TYPE_NAME> IS
REFCURSOR RETURN <RETURN_DATA_TYPE>
2.Weak Refcursor
SYN : TYPE <TYPE_NAME> IS
REFCURSOR
Thank you,
Suresh
| Is This Answer Correct ? | 11 Yes | 2 No |
How can a function retun more than one value in oracle with proper example?
how can you create an empty table from an existing table? : Sql dba
What is the difference between subquery and correlated query?
What is a design view?
Explain the usage of WHERE CURRENT OF clause in cursors ?
What is dialect in sql?
Explain polymorphism in pl/sql.
What does desc stand for?
Why we use triggers in mysql?
Why functions are used in sql?
What is identity column in sql server?
what are the advantages of cursors than procedures?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)