oracle資料庫----游標

來源:互聯網
上載者:User

標籤:資料   sys   show   name   set   屬性   output   declare   server   

                                  游標的屬性和限制

/*
1、游標的屬性
%found %notfound
%isopen 判斷游標是否開啟
%rowcount 受影響的行數
2、游標的限制
預設的情況下,oracle資料庫只允許在同一個會話中,開啟300個游標

開啟SQL PLUS:輸入show parameter cursor

 


修改游標數的限制:
alter system set open_cursors=400 scope=both;
scope的取值:both,memory,spfile(資料庫需要重啟).
{ memory:只更改當前執行個體不更改參數檔案
spfile:只更改參數檔案不更改當前執行個體
scope=spfile 僅僅更改spfile裡面的記載,不更改記憶體,也就是不立即生效,而是等下次資料庫啟動生效。有一些參數只允許用這種方法更改
scope=memory 僅僅更改記憶體,不改spfile。也就是下次啟動就失效了
scope=both 記憶體和spfile都更改
不指定scope參數,等同於scope=both.}
*/
set serveroutput on

declare
--定義游標
cursor c1 is select names,score from table1 ;
pname table1.names%type;
pscore table1.score%type;
begin
--開啟游標
open c1;
loop
--取出一行的記錄
fetch c1 into pname,pscore;
exit when c1%notfound;

dbms_output.put_line(pname||‘的成績為:‘||pscore);
dbms_output.put_line(‘受影響的行數為:‘||c1%rowcount);
end loop;
/*if c1%isopen then dbms_output.put_line(‘游標已經開啟!‘);
else
dbms_output.put_line(‘游標沒有開啟!‘);
end if;*/
--關閉游標
close c1;

end;
/

 

oracle資料庫----游標

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.