Solved

Differences between cursor and refcursor

Posted on 2003-11-24
3
1,249 Views
Last Modified: 2008-02-26
Please can anybody list out the differences between the Cursor and REFCursor.

Preparing for an interview.. Please list out any other related questions for interview purpose.

Thanks in advance.
0
Comment
Question by:king0452
3 Comments
 
LVL 15

Accepted Solution

by:
andrewst earned 250 total points
ID: 9809814
A cursor is constant: it is linked to one defined query like this:

declare
  cursor c1 (p_deptno in emp.deptno%TYPE) is select ename from emp where deptno = p_deptno;
  ...

A ref cursor is a cursor variable: the actual query can be changed at runtime like this:

procedure p( param1 in number ) is
  type rc is ref cursor;
  c1 rc;
begin
  if param1 = 1 then
    open rc for select * from emp;
  else
    open rc for select * from dept;
  end if;
  ...

Ref cursors are also used in dynamic SQL, where the query is defined as a text string, like this:

procedure p( p_sql in varchar2 ) is
  type rc is ref cursor;
  c1 rc;
begin
  open rc for p_sql;
  ...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Schema creation in Oracle12c 6 48
database upgrade 8 79
Deleting Rows from an Oracle Database - Performance 19 50
Create Index on a Materialized View 5 24
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question