set ANSI_NULLS ON
set QUOTED_IDENTIFIER ONgo -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> --QN_GOODS_ADJUST_LIST 1,'grsssss',',15,1,'-- ============================================= ALTER PROCEDURE [dbo].[QN_GOODS_ADJUST_LIST] @UserID int, @Parastr varchar(1000) = '', @WebPara varchar(100)='' AS BEGIN SET NOCOUNT ON; declare @rid int declare @ptype int declare @spelltype int --输入法类型 -- 获取操作者的关联信息 select @rid = rid, @ptype = p_type from person where p_lsm = @userid create table #ts ( sortid int identity(1,1) ,DATAKEY INT ,GAID int ,GAGoodsID varchar(100) ,GAProvider varchar(100) ,GACustomer varchar(100) ,[State] varchar(10) ) declare @outstr varchar(100) declare @gcode varchar(100) declare @gtype int exec v6_popfirstword @Parastr output, @outstr output set @gcode=@outStr set @gtype=dbo.Pub_GetCodeType(@gcode) declare @sql varchar(1000) set @sql = ' insert #ts ( datakey ,GAID ,GAGoodsID ,GAProvider ,GACustomer ,State ) select a.GAID as datakey ,a.GAID ,b.goodsname --GAGoodsID ,c.corpname --GAProvider ,d.corpname --GACustomer ,case State when 1 then ''是'' else ''否'' end State from DPV_GOODSADJUST a inner join bdo_goods b on a.gagoodsid = b.goodsid inner join BDO_CORPORATION c on a.gaprovider = c.corpid inner join BDO_CORPORATION d on d.corpid = a.GACustomer where 1=1 ' declare @clause varchar(300) set @clause='' -- if @gtype=2 -- set @clause=@clause+' and a.spell like ''%'+@gcode+'%''' -- else if @gtype=3 set @clause=@clause+' and b.GoodsName like ''%'+@gcode+'%''' else if @gtype=2 set @clause=@clause+' and b.SpellCode like ''%'+@gcode+'%''' set @sql = @sql + @clause declare @sortstr varchar(100) declare @pagenum int declare @pageno int exec PUB_WEB_PAGEPARA @WebPara, @SortStr output, @PageNum output , @PageNo OUTPUT --排序处理 --注意:很多时候,排序字段与输出字段不一致,需要做变更处理 if @sortstr is null or @sortstr = '' set @sql = @sql + ' order by datakey' else begin -- 对排序字段进行名称变更 set @sql = @sql + ' order by ' + @sortstr end print @sql exec (@sql) declare @count int select @count = count(*) from #ts if @pagenum is null or @count < @pagenum -- 行数少于每页行数 select @count as totalcount, * from #ts else select @count as totalcount, * from #ts where sortid > (@pageno - 1) * @pagenum and sortid <= @pageno * @pagenum END