oracle cursor游标获取首末元素

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;
请使用浏览器的分享功能分享到微信等