Oracle 分页语句,存储过程
select * from (select t.*,rownum rn from (select * from emp) t where rownum<=10) where rn>=6;
创建分页结果集的游标
create or replace package fenyepackage as
type testcursor is ref cursor;
end fenyepackage;
创建分页存储过程
create or replace procedure fenye3(
tableName varchar2, --表名
currPage number, --当前页
currPageSize number, --页大小
countRows out number, --总记录数
countPages out number, --总页数
fenyecursor out fenyepackage.testcursor --当前页结果集
)is
v_sql varchar2(1000);
v_begin number:=(currPage-1)*currPageSize + 1;
v_end number:=currPage*currPageSize;
begin
v_sql:='select * from (select t.*,rownum rn from (select * from '|| tableName ||') t where rownum<='|| v_end ||')
where rn>='||v_begin;
open fenyecursor for v_sql;
v_sql:='select count(*) from '|| tableName;
execute immediate v_sql into countRows;
if mod(countRows,currPageSize)=0 then
countPages:=countRows/currPageSize;
else
countPages:=countRows/currPageSize+1;
end if;
close fenyecursor;
end;
相关文档:
由于以前都是在sqlserver 2005处理,现在客户要求oracle数据库服务器,
最初的代码为:
allRecordSize = (Integer) rs1.getObject(1); //Integer allRecordSize=0;
当执行的时候报:BigDecimal无法转化为Integer类型
为了兼容两者修改后的代码为:
Object o = rs1.getObject(1);
&nbs ......
oracle表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
当前任何版本的ORACLE客户端在任何版本的WINDOWS7上都不能正常完成安装。
主要是因为ORACLE安装的先决条件里操作系统版本不符合,但是这个疑问可以修改refhost.xml处理, 具体是在refhost.xml中添加
<!--Microsoft Windows 7-->
<OPERATING_SYSTEM>
& ......
oracle不同版本间数据的导入导出
Oracle的imp/exp组件是我们常用的工具,它的一个操作原则就是向下兼容。下面是据此总结的几个使用规则和相关测试:
规则1:低版本的exp/imp可以连接到高版本(或同版本)的数据库服务器,但高版本的exp/imp不能连接到低版本的数据库服务器
1.1 使用9i客户端通过imp连 ......
NULL指的是空值,或者非法值。
NVL (expr1, expr2)->expr1为NULL,返回expr2;不为NULL,返回expr1。注意两者的类型要一致
NVL2 (expr1, expr2, expr3) ->expr1不为NULL,返回expr2;为NULL,返回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型
NULLIF (expr1, expr2) ->相等返回NULL,不等返回ex ......