--while循环访问游标
declare
cursor cur_dept is
select * from dept;
v_dept cur_dept%rowtype;
begin
open cur_dept;
fetch cur_dept into v_dept;
while cur_dept%found
loop
dbms_output.put_line(v_dept.dname);
fetch cur_dept into v_dept;
end loop;
close cur_dept;
end;
--returning返回某一值
declare
v_sal emp.sal%type;
begin
select sal into v_sal from emp where ename='SMITH';
dbms_output.put_line(v_sal);
update emp set sal=sal+100 where ename='SMITH' returning sal into v_sal;
if v_sal >850 then
dbms_output.put_line(v_sal);
rollback;
end if;
end;