Skip to Content
Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts
book

Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts

by John Adolph Palinski
August 2002
Intermediate to advanced content levelIntermediate to advanced
528 pages
10h 12m
English
Addison-Wesley Professional
Content preview from Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts

Cursor Variables

Cursor variables are a special PL/SQL type that allows a procedure to return the rows from a cursor to a calling application. This can be useful when you want to switch cursors dynamically, as you will see in Listing 16.1, or to return multiple rows from a procedure. The cursor variable designates an area of memory that stores the returned rows from the procedure.

Two steps are needed to create a cursor variable:

  • Declare the cursor as a REF CURSOR type.

  • Define a cursor variable using the type.

Here is a syntax example of the declaration:

				Type
				type_name
				is ref cursor return
				return_type;
				Cursor_variable_name         type_name;
			

The return type can be a data type or a PL/SQL record. When the return data type is included, the cursor variable ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Expert PL/SQL Practices for Oracle Developers and DBAs

Expert PL/SQL Practices for Oracle Developers and DBAs

John Beresniewicz, Adrian Billington, Martin Büchi, Melanie Caffrey, Ron Crisco, Lewis Cunningham, Dominic Delmolino, Sue Harper, Torben Holm, Connor McDonald, Arup Nanda, Stephan Petit, Michael Rosenblum, Robyn Sands, Riyaj Shamsudeen
Beginning Oracle SQL: for Oracle Database 12c, Third Edition

Beginning Oracle SQL: for Oracle Database 12c, Third Edition

Lex De Haan, Tim Gorman, Inger Jørgensen, Melanie Caffrey

Publisher Resources

ISBN: 0201752948Purchase book