zoukankan      html  css  js  c++  java
  • 存储过程分面

     1 create proc GetItems
     2 (
     3     @id  int
     4     ,@cid int
     5     ,@PageIndex int = 0 
     6     ,@PageSize int = 20 
     7     ,@TotalRecords int output
     8 )
     9 as
    10 begin
    11     declare @ResultTable table
    12     (
    13         RowIndex int
    14         ,[id] int 
    15         ,[title]        varchar(25)  not null            --标题
    16         ,[Cutoff]        datetime        not null        --截止时间
    17         ,[url]            varchar(500)    not null        --连接地址
    18         ,[imgfile]        varchar(500)    not null        --图片连接
    19         ,[Oriprice]        numeric(8,2)    not null        --原价
    20         ,[price]        numeric(8,2)    not null        --当前价格
    21         ,[cid]            int                not null        --类型
    22     );
    23     
    24     Insert into @ResultTable 
    25     select row_number() over (order by id desc) as RowIndex, 
    26         [id]
    27         ,[title]    
    28         ,[Cutoff]        
    29         ,[url]            
    30         ,[imgfile]        
    31         ,[Oriprice]        
    32         ,[price]        
    33         ,[cid]            
    34         from [Items]
    35             where  id=(
    36                 case when @id is not null or @id<=0
    37                 then @id
    38                 else
    39                     [id]
    40                     end
    41             )
    42             and cid=(
    43                 case when @cid is not null or @cid<=0
    44                 then @cid
    45                 else
    46                     [cid]
    47                     end
    48             )
    49             
    50     select  @TotalRecords = count(*) from  @ResultTable; 
    51     
    52     select * 
    53         from   @ResultTable 
    54         where  RowIndex > (@PageSize * (@PageIndex-1)) 
    55                 and RowIndex <= (@PageSize * (@PageIndex));
    56 end
  • 相关阅读:
    机器学习之朴素贝叶斯
    机器学习之KNN
    格式化数字
    web.xml中load-on-startup的作用
    ExecutorService线程池
    201404转成 2014.04
    DBCP连接池配置示例
    java 写文本换行
    打印IP 来源
    MySQL分库分表的一些技巧
  • 原文地址:https://www.cnblogs.com/gxivwshjj/p/3340378.html
Copyright © 2011-2022 走看看