DB2 Version 9.7 for Linux, UNIX, and Windows

CURSOR_ROWCOUNT scalar function

Read syntax diagramSkip visual syntax diagram
>>-CURSOR_ROWCOUNT--(--cursor-variable-name--)-----------------><

The schema is SYSIBM.

The CURSOR_ROWCOUNT function returns the cumulative count of all rows fetched by the specified cursor since the cursor was opened.

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 prior to 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.

Examples

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);