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

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle Database 12c PL/SQL Advanced Programming Techniques

Oracle Database 12c PL/SQL Advanced Programming Techniques

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Errata Page