plsqプログラム設計--カーソル
カーソルのプロパティ:
notfoundデータが見つかりませんtrueを返します
foundデータを見つけてtrueを返す
rowcountカーソル現在位置
カーソル内のすべてのデータのループ取得
notfoundデータが見つかりませんtrueを返します
foundデータを見つけてtrueを返す
rowcountカーソル現在位置
declare
-- , select
cursor c is
select * from emp;
v_emp c%rowtype;
begin
-- , select
open c;
-- fetch , 。 ,
fetch c into v_emp;
dbms_output.put_line(v_emp.ename);
close c;
end;
カーソル内のすべてのデータのループ取得
declare
cursor c is
select * from emp;
v_emp c%rowtype;
begin
open c;
loop
fetch c into v_emp;
exit when (c%notfound);
dbms_output.put_line(c%rowcount);
dbms_output.put_line(v_emp.ename);
end loop;
close c;
end;
declare
cursor c is
select * from emp;
v_emp c%rowtype;
begin
open c;
fetch c into v_emp;
while (c%found) loop
dbms_output.put_line(c%rowcount);
dbms_output.put_line(v_emp.ename);
fetch c into v_emp;
end loop;
close c;
end;
declare
cursor c is
select * from emp;
begin
for v_emp in c loop
dbms_output.put_line(c%rowcount);
dbms_output.put_line(v_emp.ename);
end loop;
end;