declare
cursor c is
select * from emp;
v_temp c%rowtype;
begin
open c;
fetch c into v_temp;
while(c%found) loop
dbms_output.put_line(v_temp.ename);
fetch c into v_temp;
end loop;
close c;
end;
//以上代码是在while循环中使用游标
declare
cursor c is
select * from emp;
--v_emp c%rowtype;
begin
for v_emp in c loop
dbms_output.put_line(v_emp.ename);
end loop;
end;
//以上代码是在for循环中使用游标
cursor c is
select * from emp;
v_temp c%rowtype;
begin
open c;
fetch c into v_temp;
while(c%found) loop
dbms_output.put_line(v_temp.ename);
fetch c into v_temp;
end loop;
close c;
end;
//以上代码是在while循环中使用游标
declare
cursor c is
select * from emp;
--v_emp c%rowtype;
begin
for v_emp in c loop
dbms_output.put_line(v_emp.ename);
end loop;
end;
//以上代码是在for循环中使用游标