標籤:資料 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資料庫----游標