Home » SQL & PL/SQL » SQL & PL/SQL » Ref Cursors VS. Cursors
Ref Cursors VS. Cursors [message #45040] Mon, 09 February 2004 02:52 Go to next message
Debraj Ghosh Dastidar
Messages: 44
Registered: February 2003
Member
I got to know, What is Ref Cursor (in brief)
and the difference between Ref Cursor and Cursor.
any help will be appricitated.
Re: Ref Cursors VS. Cursors [message #45043 is a reply to message #45040] Mon, 09 February 2004 05:03 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Re: Ref Cursors VS. Cursors [message #45555 is a reply to message #45040] Tue, 23 March 2004 19:04 Go to previous messageGo to next message
Shivakumar P
Messages: 2
Registered: March 2004
Junior Member
Ref Cursor :
The cursor definition will be dynamic and wherever we want to change the select statement, we can change.
its declaration:
TYPE refcurname is REF CURSOR return datatype;

Definition :
OPEN refcurname for
select statement;

For ref cursor, there is no need of explicit call for open and close cursors.

Normal Cursor :
Just reverse of the ref cursor. only one and static definition to the cursor. You cannot define the same cursor more than once.instead you can only use it.

declaration & definition:
Cursor curname is
select statement;

Usage :
open curname;
fetch curname into variable;
close curname;

For this type of cursors, it requires explicit close and open functions to use.

i hope i cleared to some extent.
Re: Ref Cursors VS. Cursors [message #45556 is a reply to message #45040] Tue, 23 March 2004 19:24 Go to previous messageGo to next message
Shivakumar P
Messages: 2
Registered: March 2004
Junior Member
Hi guys,
slight changes in the reply i sent before.
You can use the OPEN and CLOSE functions to ref cursor for opening and closing the cursor as exactly as we are using in the normal cursors.

thank you,
Re: Ref Cursors VS. Cursors [message #109500 is a reply to message #45555] Thu, 24 February 2005 21:10 Go to previous messageGo to next message
Rathi
Messages: 4
Registered: April 2003
Junior Member
defn was really good.
thanx
Re: Ref Cursors vs Cursors [message #109513 is a reply to message #109500] Fri, 25 February 2005 03:31 Go to previous message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
A Ref Cursor is a variable, so you can pass it between procedures/functions. It is not necessarily dynamic.

For example, I had some migration code that needed to apply 15 different updates to a large set of data, so I wrote one procedure that did the actual update (bulk collect, FORALL, capture some stats at the end etc etc), and 15 procedures that simply declared a ref cursor and passed it to the update procedure.
Previous Topic: Query to select second maximum salary from emp table
Next Topic: Partition table
Goto Forum:
  


Current Time: Tue Jul 22 13:52:12 CDT 2025