Cursor Concept: A cursor is a PL/SQL control structure that enables the display control of the processing of the statement, making it easier to process the row data of the table. Cursors are not database objects, but are persisted in memory.
Procedure: Defining Cursors Cursor cursor_name is selete_statment
The cursor declaration section is the only step that can appear in the Module declaration section, and the other three steps are in the execution and exception handling sections
The cursor name is a table identifier, so there are scopes and must be explained before use
Any SELECT statement is legal, but select ... INTO statement is illegal
Declaring a cursor at the end of a declaration section
Opens the cursor open cursor_name
Open cursor: Executes the SELECT statement corresponding to the cursor, puts its query results in the workspace, and the pointer points to the header of the workspace, identifies the cursor result collection
PL/SQL program cannot open a cursor repeatedly with an open statement
Remove the cursor FETCH cursor_name into {variable_list};
At this point, the result is a row of data, the data rows in the result collection are retrieved, and placed in the specified output variable.
Close the cursor close cursor_name
When the cursor result collection data is extracted and processed, the cursor should be closed in a timely manner to release the system resources used by the cursor and render the cursor's workspace invalid, and the FETCH statement can no longer fetch the data. The closed cursor can be reopened using the Open statement.
Cursor Properties:
Overview of Oracle Cursors