What are the Diff B/W Cursor and REF Cursor

Answer Posted / anil

1.REF CURSOR  is basically a data type. It is normally declared as type r_cursor is REF CURSOR.
CURSOR is not a datatype.
2.REF CURSOR is dynamic , CURSOR is static
3.REF CURSOR can be passed from one procedure to other procedure but CURSOR cant be passed from one procedure to other.
4. A ref cursor can not be used in CURSOR FOR LOOP, it must be used in simple CURSOR LOOP statement.
5. A ref cursor is defined at runtime and can be opened dynamically but a regular cursor is static and defined at compile time.
6. A ref cursor can be passed to another PL/SQL routine (function or procedure) or returned to a client. A regular cursor cannot be returned to a client application and must be consumed within same routine.
7) A ref cursor incurs a parsing penalty because it cannot cached but regular cursor will be cached by PL/SQL which can lead to a significant reduction in CPU utilization.
8) A regular cursor can be defined outside of a procedure or a function as a global package variable. A ref cursor cannot be; it must be local in scope to a block of PL/SQL code.
9) A regular cursor can more efficiently retrieve data than ref cursor. A regular cursor can implicitly fetch 100 rows at a time if used with CURSOR FOR LOOP. A ref cursor must use explicit array fetching.

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you go back in sql?

701


What are the different type of joins in sql?

722


What are the three pl sql block types?

724


What is the difference between function and procedure in pl/sql?

748


what are the differences between char and nchar? : Sql dba

797






How do I view a view in sql?

697


How to add new employee details in an employee_details table with the following details

823


what are all different types of collation sensitivity? : Sql dba

710


What is the difference between a primary key and a unique key?

750


Is sql open source?

713


What is the difference between numeric and autonumber?

703


What is the difference between nvl function, ifnull function, and isnull function?

798


What is optimistic concurrency control? : Transact sql

746


Write a sql query to find the names of employees that begin with ‘a’?

743


Write a unique difference between a function and a stored procedure.

714