This example shows how you can modularize the various operations on cursor variables 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 of a given department:
This variation opens the given cursor variable with a SELECT command that retrieves all rows but from a different table. 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:
This anonymous block executes all the previous programs:
The following is the output from the anonymous block: