• 循环处理--sqlserver


    alter PROCEDURE [dbo].[sp_gongzi] @gongzi_yf varchar(7) as
    DECLARE  @input_id varchar(20)
    DECLARE  @sk_sum decimal(18, 3)
    DECLARE  @sk_sum_yk decimal(18, 3)
    BEGIN 
        DECLARE cur_input CURSOR  FOR
                select docno from  tc_tab1 where yf = @gongzi_yf    
     
     OPEN cur_input
     
        FETCH  cur_input INTO @input_id
     WHILE @@FETCH_STATUS = 0
          BEGIN
             set @sk_sum = 0    
             set @sk_sum_yk  = 0
             select @sk_sum =  sum(je * case when (hl2 is null) then hl else hl2 end )         
                 from sk_dan where docno =@input_id;
            
             select @sk_sum_yk =  sum(je * case when (hl2 is null) then hl else hl2 end )         
                 from sk_dan_yk where docno =@input_id;       
                   
            set @sk_sum = case when (@sk_sum is null) then 0 else @sk_sum end;       
            set @sk_sum_yk =  case when (@sk_sum_yk is null) then 0 else @sk_sum_yk end;       
           
            update    tc_tab1 set dke2 =  @sk_sum   +   @sk_sum_yk
         where docno = @input_id; 
           
       FETCH  cur_input INTO @input_id
          END
        CLOSE cur_input
        DEALLOCATE cur_input 
        --*/
    END

  • 相关阅读:
    win7 重装 docker 启动后无法启动错误解决
    ASP.NET MVC 播放远程服务器上的MP3文件
    ubuntu+mono+PetaPoco+Oracle+.net 程序部署
    .NET Core 2.0 问题杂记
    博客园挂了吗?
    Content-Type: application/vnd.ms-excel">
    Storm
    Razor语法
    类型后面加问号 int?
    Apache vue site configuration
  • 原文地址:https://www.cnblogs.com/szlixin/p/4870944.html
Copyright © 2020-2023  润新知