易截截图软件、单文件、免安装、纯绿色、仅160KB

ORACLE用LIMIT实现类似分页

练习了ORACLE类似的分页,目的:ORACLE的LIMIT使用
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]


相关文档:

ORACLE程序包

程序包
 
包主体/规范名字一样
包主体/规范中的对应参数必须类型及名字一样
只能使用强类型的REF游标
 
创建程序包规范
create or replace package my_pack
is
       procedure find_emp_proc(eno emp.empno%type);
       function fin ......

ORACLE过程、函数

过程、函数
 
 
 
create or replace procedure p1
is
  empname emp.ename%type;
begin
  select ename into empname from emp where empno=7788;
  dbms_output.put_line(empname);
end;
 
SQL> ed
SQL> /
 
Procedure created
 
SQL> exec p1; ......

Oracle常用系统表查询

-- get all dictionary for oracle db
select * from dict;
--select * from dictionary;
-- get all columns for dictionarys
select * from dict_columns;
-- get the default name-space for current user
select username,default_tablespace from user_users;
-- get roles for current user
select * from us ......

Oracle 操作函数

函数:
 1.使用Create Function 语句创建
 2.语
法:
     Create or replace Function  函数名[参数列表]
     Return  数据类型
IS|AS
            局部变量
     Be ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号