Oracle® Database PL/SQL User's Guide and Reference 10g Release 2 (10.2) Part Number B14261-01 |
|
|
PDF · Mobi · ePub |
The CLOSE
statement indicates that you are finished fetching from a cursor or cursor variable, and that the resources held by the cursor can be reused.
close ::=
Keyword and Parameter Description
cursor_name, cursor_variable_name, host_cursor_variable_name
When you close the cursor, you can specify an explicit cursor or a PL/SQL cursor variable, previously declared within the current scope and currently open.
You can also specify a cursor variable declared in a PL/SQL host environment and passed to PL/SQL as a bind variable. The datatype of the host cursor variable is compatible with the return type of any PL/SQL cursor variable. Host variables must be prefixed with a colon.
Once a cursor or cursor variable is closed, you can reopen it using the OPEN
or OPEN-FOR
statement, respectively. You must close a cursor before opening it again, otherwise PL/SQL raises the predefined exception CURSOR_ALREADY_OPEN
. You do not need to close a cursor variable before opening it again.
If you try to close an already-closed or never-opened cursor or cursor variable, PL/SQL raises the predefined exception INVALID_CURSOR
.
For examples, see the following: