Skip to Main 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 content levelIntermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Intermediate

Q:

12-7.

Here is one possible implementation:

DECLARE
   TYPE emp_cvt IS REF CURSOR RETURN employee%ROWTYPE;
   employees emp_cvt;
   one_employee employees%ROWTYPE;
BEGIN
   OPEN employees FOR SELECT * FROM employee;
   LOOP
      FETCH employees INTO one_employee;
      EXIT WHEN employees%NOTFOUND;
      double_salary (one_employee.employee_id, one_employee.salary);
   END LOOP;
   CLOSE employees;
END;
/

Q:

12-8.

Here are the rules to keep in mind in solving this problem:

  1. The statement must be valid.

  2. The number and datatypes of the record being declared must be compatible with the record structure in the RETURN clause of the REF CURSOR statement.

The declarations are:

  1. Valid. This statement (as well as (e) and (g)) declares records that can be used in FETCH statements against the_finest_cv cursor variable. This one declares a standard table-based record, exactly the same structure used in the REF CURSOR.

  2. Invalid. Doesn’t compile. You can’t use %ROWTYPE against a REF CURSOR, only against a cursor variable.

  3. Invalid. Doesn’t compile. You can’t declare a record of type REF CURSOR; you can only declare cursor variables based on REF CURSOR types.

  4. Invalid. Doesn’t compile. You need to add %ROWTYPE to this statement.

  5. Valid. This statement relies on a programmer-defined record that has the same structure as the table, so that works just fine.

  6. Invalid. Doesn’t compile. You can’t put a %ROWTYPE at the end of a record TYPE; it already is a type.

  7. Valid. This statement demonstrates that you can declare a record from a 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

Oracle Database 12c PL/SQL Programming

Oracle Database 12c PL/SQL Programming

Michael McLaughlin
Oracle PL/SQL for DBAs

Oracle PL/SQL for DBAs

Arup Nanda, Steven Feuerstein
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page