表A01 中 有字段:ID ,数量A, 单位, 数量B
当A01中 新增一条记录时 如果 数量A 大于 零 时,单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A除以 0.9144;
当A01表中, 1、修改 数量A 时,如果 单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A 除以 0.9144; 2、修改 单位 时,如果 单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A 除以 0.9144;
当A01中 新增一条记录时 如果 数量A 大于 零 时,单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A除以 0.9144;
当A01表中, 1、修改 数量A 时,如果 单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A 除以 0.9144; 2、修改 单位 时,如果 单位='Y' 时 数量B 等于 数量A;单位='M' 数量B 等于 数量A 除以 0.9144;
after insert,delete
as
if not exists(select 1 from deleted)
update a
set 数量B=case when i.数量A>0 and i.单位='Y' then i.数量A/0.9144 else a.数量B end
from A01 a
inner join inserted i on a.ID=a.ID
else if update(数量A) or update(单位)
update a
set 数量B=case when i.单位='Y' then 数量A when i.单位='M' else i.数量A/0.9144 end
from A01 a
inner join inserted i on a.ID=a.ID
after insert,update
as
if insert
update 数量B=数量A where 数量A>0 and 单位='Y'
update 数量B=数量A/0.9144 where 数量A>0 and 单位='M'
if update(数量A)
update A01 set 数量B=数量A where 单位='Y'
update A01 set 数量B=数量A/0.9144 where 单位='M'
else if update(单位)
update A01 set 数量B=数量A where 单位='Y'
update A01 set 数量B=数量A/0.9144 where 单位='M'