%ROWCOUNT v13
The %ROWCOUNT
attribute returns an integer showing the number of rows fetched so far from the specified cursor.
cursor_name
is the name of the cursor for which %ROWCOUNT
returns the number of rows retrieved thus far. After the last row has been retrieved, %ROWCOUNT
remains set to the total number of rows returned until the cursor is closed at which point %ROWCOUNT
will throw an INVALID_CURSOR
exception if referenced.
Referencing %ROWCOUNT
on a cursor before it is opened or after it is closed, results in an INVALID_CURSOR
exception being thrown.
%ROWCOUNT
returns 0
if it is referenced when the cursor is open, but before the first FETCH
. %ROWCOUNT
also returns 0
after the first FETCH
when there are no rows in the result set to begin with.
The following example uses %ROWCOUNT
.
This procedure prints the total number of rows retrieved at the end of the employee list as follows: