• insert/process multirecords without cursor


    if object_id('Pr_ToSolver_ds_in_item_group_loc_period') is not null
        drop proc Pr_ToSolver_ds_in_item_group_loc_period


    create proc Pr_ToSolver_ds_in_item_group_loc_period
    as

    insert into  ds_in_item_group_loc_period
        (
        item_group_name
        ,loc_name
        ,bucket_from_name
        ,bucket_to_name
        ,cc
        ,cc_ratio
        ,cc_ratio_over
        ,cc_over
        ,request_fixed_under
        ,request_fixed_over
        ,request_fix
        ,zero_out_build
        )

    select
      distinct   ig.ItemGroupName
        ,l.LocationName
        ,ltrim(str(b1.YearCode))+case
                                    when b1.WorkWeekCode<=9 then '0'+ltrim(str(b1.WorkWeekCode))
                                    when b1.WorkWeekCode>9 then ltrim(str(b1.WorkWeekCode))
                                   end
           as bucket_from_name
          ,ltrim(str(b2.YearCode))+case
                                    when b2.WorkWeekCode<=9 then '0'+ltrim(str(b2.WorkWeekCode))
                                    when b2.WorkWeekCode>9 then ltrim(str(b2.WorkWeekCode))
                                   end
           as bucket_to_name
          ,ilp.Capacity
          ,ilp.CapacityRatio
          ,0
        ,0
        ,0
        ,0
        ,0
        ,0
       
    from
        ItemGroup_Location_Period ilp
        join ItemGroup ig
            on    ilp.ItemGroupId=ig.ItemGroupId
        join Location l
            on ilp.LocationId=l.LocationId
        left join Bucket b1
            on ilp.BucketId_From =b1.BucketId
        left join Bucket b2
            on ilp.BucketId_To =b2.BucketId
      
       

      
  • 相关阅读:
    每日二题20201117(34. 在排序数组中查找元素的第一个和最后一个位置)
    【CQOI2011】动态逆序对
    P3584 [POI2015]LAS
    P4643 [国家集训队]阿狸和桃子的游戏
    【CF555E】Case of Computer Network
    P3810 【模板】三维偏序(陌上花开)
    P3391 【模板】文艺平衡树(Splay)
    P3690 【模板】Link Cut Tree (动态树)
    【CF161D】Distance in Tree
    P3806 【模板】点分治1
  • 原文地址:https://www.cnblogs.com/Winston/p/1042650.html
Copyright © 2020-2023  润新知