Incorrect Syntax for usage of Cursor Names
The following statements are incorrect syntax for usage of cursor names
pet_info is the cursor name):
pet_info := 15000;
If pet_info is not NULL then
Keyword and Parameter Descriptions
- cursor_name: The name of an open explicit cursor that was declared within the current scope.
- cursor_variable_name: The name of an open cursor variable that was declared in the current scope.
- host_cursor_variable_name: The name of an open cursor variable that was declared in a PL/SQL host environment and passed to
PL/SQL as a bind argument.
Oracle provides a powerful feature in the SQL language: the cursor expression. A cursor expression, denoted by the CURSOR operator, returns a nested cursor from within a query. Each row in the result set of this nested cursor can contain the usual range of values allowed in a SQL query; it can also contain other cursors as produced by subqueries.
The CURSOR syntax, although first introduced in Oracle8i Database SQL, was not available from within PL/SQL programs. This deficiency was corrected in Oracle9i Database Release 1; since then, SQL statements within a PL/SQL procedure or function have been able to take advantage of the CURSOR expression.
Oracle Database PL/SQL Programming
You can therefore use cursor expressions to return a large and complex set of related values retrieved from one or more tables. You can then process the cursor expression result set using nested loops that fetch from the rows of the result set,
and then additional rows from any nested cursors within those rows.
Cursor expressions can get complicated, given how complex the queries and result sets can be. Nevertheless, it’s good to know all the possible ways to retrieve data from the Oracle database
You can use cursor expressions in any of the following:
- Explicit cursor declarations
- Dynamic SQL queries
- REF CURSOR declarations and variables
You cannot use a cursor expression in an implicit query.
The syntax for a cursor expression is very simple:
The database opens the nested cursor defined by a cursor expression implicitly as soon
as it fetches the row containing the cursor expression from the parent or outer cursor.
This nested cursor is closed when:
- You explicitly close the cursor.
- The outer, parent cursor is executed again, closed, or canceled.
- An exception is raised while fetching from a parent cursor. The nested cursor is closed along with the parent cursor.