易截截图软件、单文件、免安装、纯绿色、仅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;


相关文档:

oracle 表空间操作

oracle表空间操作详解
  1
  2
  3作者:   来源:    更新日期:2006-01-04 
  5
  6 
  7建立表空间
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

oracle系统表查询【GBUnix】

【转】http://www.gbunix.com/htmldata/2004_06/2/5/article_53_1.html
oracle系统表查询【GBUnix】
 
数据字典dict总是属于Oracle用户sys的。
  1、用户:
   select username from dba_users;
  改口令
   alter user spgroup identified by spgtest;
  2、表空间:
   select * fro ......

Oracle CASE表达式


CASE表达式可以在SQL中实现if-then-else型的逻辑,而不必使用PL/SQL。CASE的工作方式与DECODE()类似,但应该使用CASE,因为它与ANSI兼容。
CASE有两种表达式:
1. 简单CASE表达式,使用表达式确定返回值.
语法:
CASE search_expression
WHEN expression1 THEN result1
WHEN expression2 THEN ......

Oracle 限制索引


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