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 10. Cursors

Beginner

Q:

10-1.

An implicit cursor is a SQL statement whose associated cursor is implicitly (performed automatically by Oracle) opened, executed, and closed. The code snippets are:

  1. An example of an implicit cursor. Any INSERT, UPDATE, or DELETE is always an implicit cursor (you never open an UPDATE’s cursor explicitly).

  2. An example of an explicit cursor.

  3. An example of an implicit cursor. A SELECT INTO is an implicit query to retrieve (you hope) a single row.

  4. A DDL (Data Definition Language) command executed in SQL*Plus. It is not a cursor inside a PL/SQL program.

  5. An example of an implicit cursor.

Q:

10-2.

An explicit cursor is a SELECT statement that is declared explicitly in a declaration section (of an anonymous block, procedure, function, or package) with the CURSOR statement, as in the following:

DECLARE
   CURSOR my_cur
   IS
      SELECT * FROM employee;

Q:

10-3.

If the implicit cursor is a SELECT INTO, the TOO_MANY_ROWS exception is raised when the cursor returns more than one row; NO_DATA_FOUND is raised if the query does not return any rows. If the cursor is an INSERT, it may also raise DUP_VAL_ON_INDEX. Finally, if the cursor contains expressions, it may also raise exceptions such as ZERO_DIVIDE and INVALID_NUMBER.

Q:

10-4.

Even though this query returns at most one row, the SQL engine fetches or attempts to fetch twice: once to retrieve the row and then again to see if the TOO_MANY_ROWS exception should be raised.

Q:

10-5.

The block could fail for any of the following reasons:

  • There ...

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