....................................................................
declare
type name_arrary_type is varray(20) of varchar2(10);
name_arrary name_arrary_type;
rowss int:=&输入页记录数;
dpno int:=&输入部门号;
v_count int:=0;
cursor emp_cursor(dpno int) is select ename from emp where deptno=dpno;
begin
open emp_cursor(dpno);
loop
fetch emp_cursor bulk collect into name_arrary limit rowss;
dbms_output.put_line('部门'||dpno||'员工:');
for i in 1..(emp_cursor%rowcount-v_count) loop
dbms_output.put_line(i||' '||name_arrary(i)||' ');
end loop;
dbms_output.put_line('当前页数:'||(v_count/rowss+1));
dbms_output.new_line;
v_count :=emp_cursor%rowcount;
exit when emp_cursor%notfound;
end loop;
dbms_output.put_line('每页['||rowss||']条记录,总页数:['||ceil(emp_cursor%rowcount/rowss)||']');
close emp_cursor;
end;
运行结果:
部门20员工:
1 SMITH
2 JONES
3 SCOTT
4 ADAMS
当前页数:1
部门20员工:
1 FORD
2 YA_PING
当前页数:2
每页[4]条记录,总页数:[2]