Skip to Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Chapter 12. Cursor Variables

Beginner

Q:

12-1.

Statement (b) describes a cursor variable. Rather than pointing directly or in a hardcoded way to a result set, a cursor variable is a pointer to a work area in the System Global Area (SGA).

Q:

12-2.

First, you must declare a cursor variable type, also known as a REF CURSOR. Then you declare a variable based on that cursor. The following is an example:

DECLARE
   TYPE emp_t IS REF CURSOR RETURN emp%ROWTYPE;
   emp_cv emp_t;

Q:

12-3.

The declarations are:

  1. Valid. This format declares a type of REF CURSOR that is not tied to any specific format or result set; this is called a weak or nonrestrictive REF CURSOR.

  2. Invalid.

  3. Invalid.

  4. Valid. This format allows you to declare cursor variables that can fetch rows having the same format as the orders table; this is called a strong or restrictive REF CURSOR.

Statements (b) and (c) are invalid. After the REF CURSOR keywords, you either have simply a semicolon or a RETURN rowtype clause, where rowtype is either a %ROWTYPE definition or the name of a previously defined record type.

Q:

12-4.

The declarations are:

  1. Valid. Only (a) is a valid cursor variable declaration based on the disasters_cvt REF CURSOR.

  2. Invalid. This declaration will fail to compile because of the %ROWTYPE attribute. A REF CURSOR type is already a type; you don’t need to %ROWTYPE it.

  3. Invalid. This declaration will compile, but it simply creates a record with the same structure as a row in the environmental_disaster table, not a cursor variable.

Q:

12-5.

Here is ...

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

Oracle Database 11g PL/SQL Programming Workbook

Oracle Database 11g PL/SQL Programming Workbook

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page