动态网站制作指南
[  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库学院 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Oracle教程 ]的信息

本月文章推荐
.Oracle的启动与关闭.
.ORACLE大型数据对象LOB几种情况的.
.关于数据库OS审计.
.配置支持MTS下分布事务的Oracle.
.Oracle PL/SQL语言入门.
.在RedHat Advanced Server4.0 up.
.oracle8i学习笔记(2).
.Oracle Portal及其门户网站.
.sendmail支持的操作系统有哪些.
.DigitalUnixVersion4.0下Oracle8.
.好用的Linux小工具:Autofs.
.oracle开发 表占用空间统计——脚.
.研究生管理信息系统的开发流程一.
.Oracle数据库内存参数调优技术的.
.关于使用SHOW_SPACE().
.浅谈备份策略.
.Oracle 10g R2特性之数据仓库和集.
.Oracle-SQL长度限制.
.单机上配置9i standby.
.RedHat8下面安装Oracle 9i笔记.

实例讲解"Oracle"数据库的分页显示

文章类别:Oracle教程 | 发表日期:2008-3-18 |



Create PROCEDURE pageTest --用于翻页的测试

--需要把排序字段放在第一列

(

@FirstID nvarchar(20)=null, --当前页面里的第一条记录的排序字段的值

@LastID nvarchar(20)=null, --当前页面里的最后一条记录的排序字段的值

@isNext bit=null, --true 1 :下一页;false 0:上一页

@allCount int output, --返回总记录数

@pageSize int output, --返回一页的记录数

@CurPage int --页号(第几页)0:第一页;-1最后一页。

)


AS


if @CurPage=0

begin

--统计总记录数

select @allCount=count(ProductId) from Product_test


set @pageSize=10

--返回第一页的数据

select top 10

ProductId,

ProductName,

Introduction

from Product_test order by ProductId

end


else if @CurPage=-1


select * from

(select top 10 ProductId,

ProductName,

Introduction


from Product_test order by ProductId desc ) as aa

order by ProductId

else


begin

if @isNext=1

--翻到下一页

select top 10 ProductId,

ProductName,

Introduction

from Product_test where ProductId > @LastID order by ProductId


else

--翻到上一页

select * from

(select top 10 ProductId,

ProductName,

Introduction

from Product_test where ProductId < @FirstID order by ProductId desc) as bb order by ProductId

end

*******************************************************************************************************

CREATE OR REPLACE PROCEDURE TABLEPAGE_SELECT(v_page_size  int, --the size of a page of list

                       v_current_page int, --the current page of list

                       v_table_name varchar2, --the talbe name

                       v_order_field varchar2,--the order field

                       v_order_sequence varchar2,--the order sequence should by "_desc"or "_asc",_is blank.

                       --v_sql_select  varchar2, --the select sql for procedure

                       --v_sql_count  varchar2, --the count sql for procedure

                       --v_out_recordcount OUT int, --the num of return rows

                       p_cursor OUT refcursor_pkg.return_cursor) as

 v_sql     varchar2(3000); --the sql for select all rows of list

 v_sql_count  varchar2(3000); --the count sql for procedure

 v_sql_order  varchar2(2000); --the order of list

 v_count    int; -- the amount rows fo original list

 v_endrownum  int; --the end row num of the current page

 v_startrownum int; --the start row num of the current page

BEGIN

 ----set the order of list

 if v_order_field!='NO' then

  v_sql_order :=' ORDER BY '|| v_order_field ||' '||v_order_sequence;

 else

   v_sql_order :='';

 end if;

 ----catch the amount rows of list

 v_sql_count:='SELECT COUNT(ROWNUM) FROM '||v_table_name;

 execute immediate v_sql_count into v_count;

 -- v_out_recordcount := v_count;

 ----set the value of start and end row

 if v_order_sequence='desc' then

  v_endrownum:=v_count-(v_current_page-1)*v_page_size;

  v_startrownum:=v_endrownum - v_page_size + 1;

 else

  v_endrownum:= v_current_page * v_page_size;

  v_startrownum := v_endrownum - v_page_size + 1;

 end if;

 ----the sql for page slide

 v_sql := 'SELECT * FROM (SELECT '||v_table_name||'.*, rownum rn FROM '||v_table_name||' WHERE rownum <= ' ||

      to_char(v_endrownum) ||' '|| v_sql_order||') WHERE rn >= ' ||

      to_char(v_startrownum)||' '||v_sql_order;

 open p_cursor for v_sql;

END TABLEPAGE_SELECT;


上一篇:详细讲解大型数据库的设计原则与开发技巧 人气:566
下一篇:带你轻松接触Oracle DBLink的简单运用 人气:457
点击此处浏览全部Oracle的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-5-16 乘风多用户PHP统计系统 v3.4
2008-5-16 轩溪下载系统 v3.78 build 0515
2008-5-16 普沙B2B 浙江省商贸网 v2.0
2008-5-16 asp抓蜘蛛的小程序 v1.0
2008-5-16 齐齐乐网私服发布站 仿haosf新版
2008-5-16 IssTech信息反馈系统 v1.0
2008-5-16 自由领域大头贴(js接口版) 修正版
2008-5-16 医院网站系统
2008-5-16 智拓-分类信息管理系统 v5.0
2008-5-7 Windows XP SP3 官方英文版
2008-5-7 Windows XP SP3 官方香港中文版
2008-5-7 Windows XP SP3 官方繁体中文版
2008-5-7 Windows XP SP3 官方简体中文版
2008-4-30 Multiple Unzip Wizard 1.02
2008-4-30 Multiple Unrar Wizard 1.0.0
2008-4-30 WinZip Install/Try/Uninstall a
2008-4-30 ZIP压缩文件修复器WzipFix 2.0
2008-4-30 Pentazip 6.01 Build 189 For Wi
  发表评论
姓 名: 验证码: [ 全部贴吧 ] [ 浏览评论 ]
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号