Cursor Properties and Restrictions
/*
1. Cursor Properties
%found%notfound
%isopen to determine if the cursor is open
%rowcount the number of rows affected
2, the cursor limit
By default, the Oracle database allows only 300 cursors to be opened in the same session
Open SQL PLUS: Enter show parameter cursor
To modify the limit of the number of cursors:
Alter system set OPEN_CURSORS=400 Scope=both;
Value of scope: Both,memory,spfile (the database needs to be restarted).
{Memory: Change the current instance without changing the parameter file
SPFile: Changing only the parameter file does not change the current instance
Scope=spfile only changes the spfile inside the record, does not change the memory, namely does not take effect immediately, but waits for the next database to start to take effect. There are some parameters that only allow this method to change
Scope=memory only changes the memory, does not change the spfile. Which means that the next launch will expire.
Scope=both memory and SPFile are changed
The scope parameter is not specified, equivalent to Scope=both.}
*/
Set Serveroutput on
Declare
--Define Cursor
Cursor C1 is a select Names,score from table1;
PName Table1.names%type;
Pscore Table1.score%type;
Begin
--Open cursor
Open C1;
Loop
--Take out a row of records
Fetch C1 into Pname,pscore;
Exit when C1%notfound;
Dbms_output.put_line (pname| | ' The result is: ' | | Pscore);
Dbms_output.put_line (' Number of rows affected: ' | | C1%rowcount);
End Loop;
/*if C1%isopen then Dbms_output.put_line (' Cursor already open! ‘);
Else
Dbms_output.put_line (' Cursor not open! ‘);
End if;*/
--Close cursor
Close C1;
End
/
Oracle Database----Cursors