The following example illustrates how the various operations on cursor variables can be modularized into separate programs.
The following procedure opens the given cursor variable with a SELECT command that retrieves all rows.
This variation opens the given cursor variable with a SELECT command that retrieves all rows, but of a given department.
This third variation opens the given cursor variable with a SELECT command that retrieves all rows, but from a different table. Also note that the function’s return value is the opened cursor variable.
This procedure fetches and displays a cursor variable result set consisting of employee number and name.
This procedure fetches and displays a cursor variable result set consisting of department number and name.
This procedure closes the given cursor variable.
The following anonymous block executes all the previously described programs.
The following is the output from the anonymous block.