sql,xz的aj的jarq为空的矫正,通过审批的最后审批通过时间

DECLARE xzajmyjarq CURSOR  FOR SELECT C_BH FROM T_XZ_AJ WHERE N_AJJZJD=10 AND D_JARQ IS NULL AND N_JAAY IS NOT NULL

 

DECLARE @b VARCHAR(50)

OPEN  xzajmyjarq

FETCH xzajmyjarq INTO @b

DECLARE @a INT

SET @a=1

WHILE @a<20

BEGIN      

UPDATE T_XZ_AJ SET D_JARQ=(SELECT  max(D_PSSJ) FROM T_CMPT_SP_PS WHERE C_ID IN( SELECT C_ID FROM T_CMPT_SP_SPHJ WHERE C_SP_ID= (SELECT C_ID FROM T_CMPT_SP_SP WHERE C_EXT3=@b AND C_SPLX_ID='0484818b46148a95014617c9f80b00c8') )) WHERE C_BH=@b

   SET @a=@a+1   

SELECT @b   

SELECT CAST(@a AS VARCHAR)     

FETCH xzajmyjarq INTO @b END CLOSE xzajmyjarq

posted @ 2017-10-05 09:43  滴滴滴  阅读(258)  评论(0编辑  收藏  举报