どのように私は、複数行の更新で動作するようにこのコードを変更することができます。@ idはint型であるとORDER_IDが主キーであるが、私は= status_bたすべての行を確認したいが更新トリガーでマルチ行の更新
select @id=inserted.order_id from inserted;
if update(status_b)
begin
if (select status_b from inserted)='bagged'
begin
if (select o.id
from [order] o
left join [print] p on o.id=p.order_id
left join [laminate] l on l.order_id=o.id
left join [slitting] s on s.order_id=o.id
left join [bagging] b on b.order_id=o.id
where
1=(case when (o.printing='دارد' and status_p='printed') or o.printing='ندارد' then 1 end)
and 1=(case when (o.lamination='دارد' and status_l1='laminated') or o.lamination='ندارد' then 1 end)
and 1=(case when (o.lamination='دارد' and l.layer2<>'' and status_l2='laminated2') or o.lamination='ندارد' then 1 end)
and 1=(case when (o.coldseal='دارد' and status_c='coldsealed') or o.coldseal='ندارد' then 1 end)
and 1=(case when (o.slitting='دارد' and status_s='slitted') or o.slitting='ندارد' then 1 end)
and 1=(case when (o.bagging='دارد' and status_b='bagged') or o.bagging='ندارد' then 1 end)
and [email protected]) is not null
begin
update [order] set [status]='finished' where [email protected]
end
end
end
「を袋詰め」
' WHERE'節に 'C.STATUS_B = 'BAGGED''を追加してください。 – MtwStark
' a.id = c.oid'は 'b.oid'ではなく、最後の行をb行目としてバギングし、' c.status_b = 'bagged'' where句で@KumarHarsh –