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

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:openrowset / oracle:table/view@dblink名

只是sqlserver 提供的远程数据访问函数;  在本地sqlserver 中取外部数据源数据时候可用;
对连接本地 oracle 操作远程 oracle 不能使用; 测试: pl/sql 中使用:
select * from openrowset(................); 无效!!!!!!!!!!!!!!
在oracle 中需要访问远程数据,需要建立一连接远程oracle 的 dblink ;
再用如下方 ......

连接oracle,sqlserver中数据库的示例代码

一 在Oracle中连接数据库
public class Test1 {
 public static void main(String[] args) {
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   Connection conn = DriverManager.getConnection(
       &nbs ......

Oracle 限制索引


 
 
限制索引是一些没有经验的开发人员经常犯的错误之一。在SQL中有很多陷阱会使一些索引无法使用。下面讨论一些常见的问题: 
 
 
1 使用不等于操作符(<>、!=)
 
 下面的查询即使在cust_rating列有一个索引,查询语句仍然执行一次全表扫描。
 
   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号