a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

實例講解"Oracle"數(shù)據(jù)庫的分頁顯示

2024-08-29 13:52:09
字體:
供稿:網(wǎng)友


Create PROCEDURE pageTest --用于翻頁的測試

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

(

@FirstID nvarchar(20)=null, --當(dāng)前頁面里的第一條記錄的排序字段的值

@LastID nvarchar(20)=null, --當(dāng)前頁面里的最后一條記錄的排序字段的值

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

@allCount int output, --返回總記錄數(shù)

@pageSize int output, --返回一頁的記錄數(shù)

@CurPage int --頁號(第幾頁)0:第一頁;-1最后一頁。

)


AS


if @CurPage=0

begin

--統(tǒng)計總記錄數(shù)

select @allCount=count(ProductId) from Product_test


set @pageSize=10

--返回第一頁的數(shù)據(jù)

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;


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久99精品国产 | 亚洲欧美精品 | 日本成人中文字幕 | 精品国产91 | 久久久久无码国产精品一区 | 欧美一级大片 | 国产视频久久久久 | 国产成人一区二区三区影院在线 | 国产免费一区 | 日韩在线欧美 | 亚洲精品一区二区三区蜜桃久 | 91视频分类 | 亚洲 中文 欧美 日韩在线观看 | 天天躁日日躁狠狠躁av麻豆 | 欧洲av一区二区 | www.av视频| 99色资源 | 国产精品久久久久久久久久免费看 | 亚洲精品日韩激情在线电影 | 视频一区 中文字幕 | 国产精品8 | 久久综合久久久 | 99动漫| 91.com在线观看 | 日日摸天天做天天添天天欢 | 美女视频一区 | 日本福利视频 | 免费v片在线观看 | 成人免费视频在线看 | 一级a性色生活片久久毛片明星 | 538在线精品| 免费在线看a | 午夜精品一区二区三区免费视频 | 日韩一区二区三区精品 | 成人免费视频网站在线观看 | 欧美性受| 亚洲综合在线一区 | 免费久久久 | www狠狠干 | 日本一区视频 | www.国产一区|