Opening a Cursor Variable v13
Once a cursor variable is declared, it must be opened with an associated SELECT
command. The OPEN FOR
statement specifies the SELECT
command to be used to create the result set.
name
is the identifier of a previously declared cursor variable. query
is a SELECT
command that determines the result set when the statement is executed. The value of the cursor variable after the OPEN FOR
statement is executed identifies the result set.
In the following example, the result set is a list of employee numbers and names from a selected department. Note that a variable or parameter can be used in the SELECT
command anywhere an expression can normally appear. In this case a parameter is used in the equality test for department number.