• Get all static wms goodlocation data


    sql function and store process:

    create function  [dbo].[fun_splitin](@c varchar(200),@split varchar(2))   
     returns @t  table(col varchar(20))   
     as  
     begin   
      while(charindex(@split,@c)<>0)   
        begin  
          insert  @t(col)values (substring(@c,1,charindex(@split,@c)-1))   
          set @c=stuff(@c,1,charindex(@split,@c),'')   
         end  
      insert @t(col)values(@c)   
     return  
    end
    create procedure [dbo].[sp_getallstaticgoodlocationdata]
         @platoon varchar(64)
    as
    begin
        if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_getstaticgoodlocationdata_temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)  
                 drop table [dbo].[t_getstaticgoodlocationdata_temp]  
                 create   table   [t_getstaticgoodlocationdata_temp](id numeric(12)  identity(1,1) primary key , the_floor int,the_column1 int,the_column2 int,the_column3 int,the_column4 int,the_column5 int,the_column6 int,the_column7 int,the_column8 int,the_column9 int,the_column10 int,the_column11 int,the_column12 int
                 ,the_column13 int,the_column14 int,the_column15 int,the_column16 int,the_column17 int,the_column18 int,the_column19 int,the_column20 int,the_column21 int,the_column22 int,the_column23 int,the_column24 int,the_column25 int,the_column26 int,the_column27 int,the_column28 int,the_column29 int,the_column30 int,
                 the_column31 int,the_column32 int,the_column33 int,the_column34 int,the_column35 int,the_column36 int,the_column37 int,the_column38 int
                 ,the_column39 int,the_column40 int)    
    
        DECLARE @the_platoon int
        DECLARE cursor_name CURSOR FOR  
            select distinct F_Platoon from Sys_GoodLocation where F_Status=1 and F_Locked='N' and F_Platoon in ((select col from dbo.fun_splitin(@platoon,',')) ) 
        OPEN cursor_name 
        FETCH NEXT FROM cursor_name INTO @the_platoon   
        WHILE @@FETCH_STATUS = 0
            BEGIN
                if @the_platoon<>0
                    begin
                        insert into [dbo].[t_getstaticgoodlocationdata_temp](the_floor,the_column1,the_column2,the_column3,the_column4,the_column5,the_column6,the_column7,the_column8,the_column9,the_column10,the_column11,the_column12 
                        ,the_column13,the_column14,the_column15,the_column16,the_column17,the_column18,the_column19,the_column20,the_column21,the_column22,the_column23,the_column24,the_column25,the_column26,the_column27,the_column28,the_column29,the_column30,
                        the_column31,the_column32,the_column33,the_column34,the_column35,the_column36,the_column37) exec sp_getgoodlocationviaplatoon @the_platoon
                    end
                FETCH NEXT FROM cursor_name INTO @the_platoon 
            END
        CLOSE cursor_name 
        DEALLOCATE cursor_name 
    
        select the_floor,convert(int,isnull(SUBSTRING(convert(varchar(12),the_column1),2,2),0)) as the_platoon,the_column1,the_column2,the_column3,the_column4,the_column5,the_column6,the_column7,the_column8,the_column9,the_column10,the_column11,the_column12 
        ,the_column13,the_column14,the_column15,the_column16,the_column17,the_column18,the_column19,the_column20,the_column21,the_column22,the_column23,the_column24,the_column25,the_column26,the_column27,the_column28,the_column29,the_column30,
        the_column31,the_column32,the_column33,the_column34,the_column35,the_column36,the_column37 from [dbo].[t_getstaticgoodlocationdata_temp] 
    end

     call:

    exec [dbo].[sp_getallstaticgoodlocationdata] '1,2,3,6'

    result:

  • 相关阅读:
    剑指offer面试题43:n个筛子的点数
    【面试题经典重温【原创】】求子数组的最大和
    C#中RSA加密解密和签名与验证的实现
    获取Treeview中CheckBox选中项的技巧(winform)
    12个优秀的云计算操作系统
    c#隐藏TextBox中闪烁的光标
    C#操作MySQL数据库的简单例子
    如何设置MySQL远程连接
    图文并茂 在MyEclipse 8.6上搭建Android开发环境
    Web开发/设计人员应当知道的15个网站
  • 原文地址:https://www.cnblogs.com/AriLee/p/10755516.html
Copyright © 2020-2023  润新知