CURSOR_ROWCOUNT scalar function
The CURSOR_ROWCOUNT function returns the cumulative count of all rows fetched by the specified cursor since the cursor was opened.
The schema is SYSIBM.
-
cursor-variable-name
- The name of a SQL variable or SQL parameter of a cursor type. The underlying cursor of the cursor-variable-name must be open (SQLSTATE 24501).
The result is 0 if no FETCH action on the underlying cursor of the cursor-variable-name was performed before the evaluation of the function.
This function can only be used within a compound SQL (compiled) statement.
The data type of the result is BIGINT. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
Example
The
following example shows how to use the function to retrieve the count
of rows associated with the cursor curEmp and assign
it to a variable named rows_fetched:
SET rows_fetched = CURSOR_ROWCOUNT(curEmp);