wie kann ich diesen Code ändern, um mit mehrreihige Update zu arbeiten. @ Id int und order_id ist Primärschlüssel, aber ich möchte jede Zeile überprüfen, die STATUS_B hat = ‚verpackt‘mehrreihige Update Update-Trigger
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
sollten Sie' C.STATUS_B = 'BAGGED'' in der 'WHERE' Klausel – MtwStark
' auf a.id = hinzufügen c.oid 'not' b.oid', links sinkend beitritt als b 3 Zeile später und 'c.status_b = 'sacked' in where Klausel @KumarHarsh –