Closing a Cursor Variable
The CLOSE statement disables the cursor variable. After that, the related result set is undefined. The syntax for the same is as shown below:
CLOSE {cursor_variable_name | :host_cursor_variable_name);
In the illustration below, if the last row is processed, then you can close the cursor variable emp_cv:
LOOP
FETCH emp_cv INTO emp_rec;
EXIT WHEN emp_cv%NOTFOUND;
-- process data record
END LOOP;
/* Close cursor variable. */
CLOSE emp_cv;
Whenever declaring a cursor variable as the formal parameter of the subprogram which closes the cursor variable, you should specify the IN or IN OUT mode.
If you attempt to close an already-closed or never-opened cursor variable, the PL/SQL raises the predefined exception that is the INVALID_CURSOR.