CREATEORREPLACEPROCEDURE GetData (MachType invarchar2, pageIndex innumber, pagesize innumber, c out sys_refcursor ) IS maxcount number(10); mincount number(10); BEGIN maxcount:=pageIndex*pagesize; mincount:=(pageIndex-1)*pagesize; --if (MachType='') then open c for select*from (select rownum id,"allinfor".*from "allinfor" where rownum<maxcount) where id>mincount; --end if; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; WHEN OTHERS THEN -- Consider logging the error and then re-raise RAISE; END GetData;
Sql server 2005
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTERprocedure[dbo].[getdata] @sMachTypevarchar(20), @pageCountint, @pagesizeint AS declare@mincountint; declare@maxcountint; set@mincount=(@pagecount-1)*@pagesize; set@maxcount=@pagecount*@pagesize; begin ifobject_id('tmp') isnotnull droptable tmp; selectidentity(int,1,1) as RowID,*into tmp from allinfor; --篶Θ斑患糤ID. if@sMachType='' begin select*from tmp where RowID between@mincountand@maxcount; end else begin select*from tmp where RowID between@mincountand@maxcountand machtype=@sMachType; end end
通常把經常用到的功能塊封裝在一起﹐待用到時統一調用即可﹐這樣可以減少代碼的書寫﹐也利于維護。對于class的封裝和user control的封裝從原理上還是有些相似。下面舉例說明user control 的使用.自定義分頁控件﹕1.新建項目﹕GridPage.ascx. 添加以下control ...@ Control Language="C#" Auto