oracle cursor遊標獲取首末元素

wisdomone1發表於2011-12-13
declare
cursor cur_dept is select dname from dept;

v_dname dept.dname%type;
v_cnt integer;
begin
select count(deptno) into v_cnt from dept;
open cur_dept;
loop
fetch cur_dept into v_dname;
exit when cur_dept%notfound;
if cur_dept%rowcount=1 then
dbms_output.put_line(v_dname);
end if;
if cur_dept%rowcount=v_cnt then
dbms_output.put_line(v_dname);
end if;

end loop;
close cur_dept;
end;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-713228/,如需轉載,請註明出處,否則將追究法律責任。

相關文章