 |
|
Oracle Tips by Burleson |
PL/SQL Cursor Attributes
Oracle provides four attributes to get information
about the state of a cursor.
cursor%found
Returns true if the last fetch returned a new
row. Before the first fetch, %found is null. After the first
fetch, (if it returned a new row) %found is true. After the
first fetch that does not return a new row, %found is false.
cursor%notfound
Returns true if the last fetch does not return a
new row. The %notfound is basically the opposite of the
%found attribute.
cursor%rowcount
Returns the number of rows that have already been
fetched. Before the first row, %rowcount is zero. As each row
is fetched, %rowcount increases by one.
cursor%isopen
Returns true if the cursor is currently open.
Before the cursor is opened and after the cursor is closed, it returns
false.
Note: all the attributes except cursor%isopenwill throw an exception if called before the cursor is opened or
after the cursor is closed.
So we have the basics for creating, testing and
using a cursor, it is time to put cursors to work.
 |
For more details and scripts, see my new book "
Oracle
Tuning: The Definitive Reference", over 900 pages
of BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot. |
|