6, how to use the display cursor,? How do I traverse a circular cursor?
① using Display Cursors
⑴ declares a cursor: divides the storage area, noting that the SELECT statement is not executed at this time.
cursor cursor name (parameter list) [return value type] is Select statement;
⑵ Open cursor: Executes a SELECT statement to obtain the result set stored in the cursor, at which point the cursor points to the result set header instead of the first record.
Open cursor name (parameter list);
⑶ Get record: Move cursor fetch a record
Fetch cursor name into temporary record or attribute type variable;
⑷ closes the cursor: puts the cursor in the buffer pool without fully releasing the resource. can be reopened.
Close cursor name;
② traversing a loop cursor
⑴for Loop Cursors
Loop Leng Open the cursor, automatically scroll to get a record, and automatically create a temporary record type variable to store the record. The cursor is automatically closed when finished processing.
For variable name in cursor name
Loop
Data processing statements;
End Loop;
⑵loop Loop Cursors
。。。
Loop
Fatch cursor name into temporary record or attribute type variable;
Exit when cursor name%notfound;
End Loop;
Cursors Cursor for Oracle