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

10-6.

Which of the following strings are valid cursor attributes (which means they are “attached” as a suffix to the name of the cursor)?

  1. %ROWNUM

  2. %FOUND

  3. %TOO_MANY_ROWS

  4. %NO_DATA_FOUND

  5. %NOTFOUND

  6. %ROWCOUNT

  7. %ISCLOSED

  8. %ISOPENED

  9. %ISOPEN

10-7.

Which of the following uses of cursor attributes are valid? If they are not valid, what is the problem? Assume that the following cursor is declared in the same block when referenced in the problems:

CURSOR possibly_in_danger_cur IS
   SELECT status
     FROM genetically_modified_foods
    WHERE product = 'CORN'
      AND animal = 'MONARCH BUTTERFLY';
  1. BEGIN
       IF possibly_in_danger_cur%FOUND
       THEN
          OPEN possibly_in_danger_cur;
  2. BEGIN
       UPDATE jobs_to_mexico
          SET total_count = 10000000
        WHERE nafta_status = 'IN FORCE';
       DBMS_OUTPUT.PUT_LINE (SQL%ROWCOUNT);
  3. BEGIN
       FOR big_loss IN possibly_in_danger_cur
       LOOP
          IF possibly_in_danger_cur%ROWCOUNT
          THEN
             ...
  4. BEGIN
       OPEN possibly_in_danger_cur;
       FETCH possibly_in_danger_cur INTO I_am_sad;
       IF I_am_sad%FOUND
       THEN
  5. FOR indx IN 1 .. 12
    LOOP
       DELETE FROM genetically_modified_foods
        WHERE product = 'CORN';
       DBMS_OUTPUT.PUT_LINE (
          'All gone:  ' || genetically_modified_foods%ROWCOUNT);
    END LOOP;

10-8.

What is wrong with the following code? Will you eventually run out of open cursors in the session if you execute this program, say, 100,000 times?

CREATE OR REPLACE FUNCTION totalsales (year_in IN INTEGER) RETURN NUMBER IS CURSOR sales_cur IS SELECT SUM (amt) FROM ...; total NUMBER; BEGIN OPEN sales_cur; FETCH sales_cur INTO total; RETURN total; CLOSE sales_cur; ...
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