11月10日 异常和游标 declare rec scott.emp%routype begin select count (*) into cnt from scott.emp if cnt > 10 then raise too many cmp end if; exception end; 一。游标: (1)静态游标 显示游标,有四个属性。 declare cursor emp-cur is select * from scott.emp; rec scott.emp%rowtype; begin open emp-cur fetch emp-cur into rec; loop exit when emp-cur%notfound; dbms-output-put-line(rec.ename); fetch emp-cur into rec; end loop; close emp-cur end; (2) 隐示游标(sql) declare begin update scott.dmpt set deptno-100 where doptna = 21; if sql%notfound then dbms_output.put_line('没有更新行!'); end if; end; 二/引用游标 declare type cur_type is ref cursor scott.emp% rowrype; emp_cur cur_type; rec scott.emp%rowtype; begin open emp_cur for select * from scott.emp; fetch emp_cur into rec; loop exit when emp_cur%notfound; dbms_cutput.put_line(rec) fetch emp_cur into rec; close emp_cur; end loop; end;