Define a Cursor Variable in Oracle

Q

How To Define a Cursor Variable in Oracle?

✍: FYIcenter.com

A

To define cursor variable, you must decide which REF CURSOR data type to use. There are 3 ways to select a REF CURSOR data type:

  • Define your own specific REF CURSOR types using the TYPE ... RETURN statement.
  • Define your own generic REF CURSOR type using the TYPE ... statement.
  • Use the system defined REF CURSOR type: SYS_REFCURSOR.

The follwoing tutorial exercise defines 3 cursor variables in 3 different ways:

CREATE OR REPLACE PROCEDURE FYI_CENTER AS
  TYPE emp_ref IS REF CURSOR RETURN employees%ROWTYPE;
  TYPE any_ref IS REF CURSOR;
  emp_cur emp_ref;
  any_cur any_ref;
  sys_cur SYS_REFCURSOR;
BEGIN
  NULL;
END;
/

 

Open a Cursor Variable in Oracle

What Is a Cursor Variable in Oracle

Working with Cursors in Oracle PL/SQL

⇑⇑ Oracle Database Tutorials

2018-07-18, 1595🔥, 0💬