What is ref cursor in pl/sql?

Questions by sandip_kate

Showing Answers 1 - 9 of 9 Answers

mahi

  • Mar 16th, 2006
 

Cursor variables are like pointers to result sets. You use them when you want to perform a query in one subprogram, and process the results in a different subprogram (possibly one written in a different language). A cursor variable has datatype REF CURSOR, and you might see them referred to informally as REF CURSORs.

  Was this answer useful?  Yes

Cnu

  • Mar 18th, 2006
 

A REF CURSOR is majorly used when we want to execute a dynamic select statement causes to retrieve more than one record. We can pass Ref cursor result as a out parameter which can be used in other subprograms.

Static cursor (general) is associated with only one SELECT statement.It can't be with many.That too we can't use at dynamic time.

Ref Cursors also known as Dynamic cursors cane be associated with as many SELECT statements you want at different times.You can associate with different SELECT stataments at dynamic time.

pramod kumar

  • Apr 6th, 2006
 

Ref cursor are the pointor to the server side cursor variables, they can be attached to diff statments and can store diff value during runtime.i mean they act basically dynamiclly , we call them as true PLSQL variable.

  Was this answer useful?  Yes

Divesh

  • Apr 23rd, 2006
 

ref cursor are just like pointer which can point to different select statements ie same cursor can be associated with different select statements

g_sidhu

  • Feb 1st, 2008
 

Cursor variables are like C or Pascal pointers, which hold the memory location (address) of some item instead of the item itself. Thus, declaring a cursor variable creates a pointer, not an item. In PL/SQL, a pointer has the datatype REF X, where REF is short for REFERENCE and X stands for a class of objects. A cursor variable has datatype REF CURSOR. Like a cursor, a cursor variable points to the current row in the result set of a multirow query. However, cursors differ from cursor variables the way constants differ from variables. A cursor is static, but a cursor variable is dynamic because it is not tied to a specific query.

  Was this answer useful?  Yes

Sadashiv

  • Aug 8th, 2011
 

REF Cursor OR Dynamic Cursors:

Query associated with cursor is not known at the time of compilation. The select statement associated with cursor is changing at the time of running the program

Syntax:

Code
  1. span style="font-style: italic;">--->Cursors which returns STRONG Cursor.

  2. --->Cursor which returns Weak Cursors

  Was this answer useful?  Yes

Sahaja Mallarapu

  • Aug 26th, 2011
 

A Ref Cursor is a variable that points to cursor.A ref cursor allows you to store the result of a "bulk collect" from a table (or any PL/SQL cursor return set) into a PL/SQL table and then reference the array with the ref cursor as a pointer.

There are two types of Ref cursors:
1.Weak ref cursor: cursor which does not have a return type in its definition.

Code
  1. span style="color: #ff0000;">'emp''Emp table opened.''Emp table closed.''dept''Dept table opened.''Emp table closed.''Table name is wrong'


Eg:

2.Strong ref cursor: cursor which has a return type in its definition.

Eg:

Code
  1. span style="color: #ff0000;">'Employee No : ''Employee Salary: '

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions