Oracle Database----Cursors

Source: Internet
Author: User

                                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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.