关联多表 更新

 

 

 

    关联多表 更新

update pggoodsstocks set pgQty = g.pgQty + bak.pgQty
            from pggoodsstocks g, (select pgDetail, CAST(round(CAST(sum(Qty) AS NUMERIC(22,10))/CAST(pgDetail AS NUMERIC(22,10)), 0, 1) AS NUMERIC(22,10)) as pgQty, IsCut from pgBakdlyDetail where vchcode = @nvchcode and dlyorder = @nOldDlyOrder group by pgDetail, IsCut) bak    
            where g.ktypeid = @szKtypeID and g.ptypeid = @szPtypeID AND goodsorderid = @ngoodsorderid and g.pgDetail = bak.pgDetail and g.IsCut = bak.IsCut and bak.pgQty <> 0
    if @@error > 0 return -2    

Sql Server 中的 @@ERROR

@@ERROR:当前一个语句遇到错误,则返回错误号,否则返回0。需要注意的是@ERROR在每一条语句执行后会被立刻重置

 

posted @ 2021-08-30 15:35  乌柒柒  阅读(37)  评论(0编辑  收藏  举报