Working with Implicit Cursors
PL/SQL declares and manages animplicit cursor every time you execute a SQL DML statement (INSERT, UPDATE, or DELETE) or a SELECT INTO that returns a single row from the database directly into a PL/SQL data structure. This kind of cursor is called implicit because Oracle implicitly or automatically handles many of the cursor-related operations for you, such as allocation of a cursor, opening the cursor, fetching, and so on.
Tip
The implicit DML statements are covered in Chapter 13. This chapter is concerned only with the implicit SQL query.
An implicit cursor is a SELECT statement that has the following special characteristics:
The SELECT statement appears in the executable section of your block; it is not defined in the declaration section, as explicit cursors are.
The query contains an INTO clause (or BULK COLLECT INTO for bulk processing). The INTO clause is a part of the PL/SQL (not the SQL) language and is the mechanism used to transfer data from the database into local PL/SQL data structures.
You do not open, fetch, or close the SELECT statement; all of these operations are done for you.
The general structure of an implicit query is as follows:
SELECTcolumn_list[BULK COLLECT] INTOPL/SQL variable list...rest of SELECT statement...
If you use an implicit cursor, Oracle performs the open, fetches, and close for you automatically; these actions are outside your programmatic control. You can, however, obtain information about the most recently ...
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