• 存储过程,稍微复杂


    if (exists (select * from sys.objects where name = 'proc_initialization_jz'))
        drop proc proc_initialization_jz
    go
    create proc proc_initialization_jz
    as
      BEGIN
      DECLARE
      @A0100    varchar(30),
      @A91A2     varchar(30),
      @A91AA     varchar(30),
      @A91A9    varchar(30),
      @A91A4   varchar(300),
      @syncKey  varchar(100),
      @MaxI9999 integer,
      @I9999    integer,
      @jz_str   varchar(300)
      DECLARE c_jz CURSOR FOR SELECT distinct A0100 FROM USRA91 WHERE A91A7='0';
      OPEN c_jz;
      FETCH NEXT FROM c_jz INTO @A0100
          WHILE (@@FETCH_STATUS = 0)
          BEGIN
           SET @jz_str=''
           DECLARE c_jz1 CURSOR FOR SELECT A91A2,A91AA,A91A9,A91A4 FROM USRA91 WHERE A0100=@A0100 and A91A7='0' order by i9999;
        OPEN c_jz1;
              FETCH NEXT FROM c_jz1 INTO @A91A2, @A91AA,@A91A9,@A91A4
            WHILE (@@FETCH_STATUS = 0)
                  BEGIN   
                  SELECT @syncKey = GUIDKEY FROM UsrA01 WHERE A0100=@A0100
                  IF LEN(@jz_str) >0 AND ISNULL(@A91A2,'') <>'' AND ISNULL(@A91AA,'')<>'' AND ISNULL(@A91A9,'')<>'' AND ISNULL(@A91A4,'')<>''
                      SET @jz_str = @jz_str + ';' +@A91A2+ '@'+ @A91AA + '@' + @A91A9 + '@' + @A91A4
                  ELSE IF ISNULL(@A91A2,'') <>'' AND ISNULL(@A91AA,'')<>'' AND ISNULL(@A91A9,'')<>'' AND ISNULL(@A91A4,'')<>''
                      SET @jz_str = @A91A2+ '@'+ @A91AA + '@' + @A91A9 + '@' + @A91A4
              FETCH NEXT FROM c_jz1 INTO @A91A2, @A91AA,@A91A9,@A91A4
        END;
           CLOSE c_jz1;
              DEALLOCATE c_jz1;
       
           IF EXISTS(SELECT 1 FROM t_hr_view WHERE t_hr_view.UNIQUE_ID=@syncKey)
              BEGIN
              UPDATE t_hr_view SET H01ST = @jz_str,sdate = GETDATE() WHERE t_hr_view.UNIQUE_ID=@syncKey;
              END;
       FETCH NEXT FROM c_jz INTO @A0100
       END;
       CLOSE c_jz;
       DEALLOCATE c_jz;
     END  

  • 相关阅读:
    .net源码分析 – List<T>【转】
    js如何安全扩展系统函数
    ASP.NET Core 资源打包与压缩
    Jwt介绍
    Asp.Net Core中JWT刷新Token解决方案【转】
    关于同步方法里面调用异步方法引起死锁【转】
    CountDownEvent
    读写锁-ReaderWriterLockSlim
    自旋锁-SpinLock
    原子操作-Interlocked(CAS算法实现)
  • 原文地址:https://www.cnblogs.com/beijingstruggle/p/4904895.html
Copyright © 2020-2023  润新知