我负责将ASA迁移到MSSQL数据库,但是我对MSSQL触发器不熟悉,有人可以将其转换为MSSQL触发器吗?
COMMENT TO PRESERVE FORMAT ON TRIGGER "DBA"."BATCH_DEDUCTIONS"."deductions_update" IS
{create TRIGGER deductions_update AFTER UPDATE OF "FACTOR", "RATE"
ORDER 1 ON "DBA"."BATCH_DEDUCTIONS"
REFERENCING OLD AS old_row NEW AS new_row
FOR EACH ROW /* WHEN( search_condition ) */
BEGIN
/* Type the trigger statements here */
declare trfactor numeric(12,6);
declare trrate numeric(12,6);
declare tramount numeric(12,2);
set trfactor = new_row.factor;
set trrate = new_row.rate;
set tramount = trfactor * trrate;
update "dba"."batch_deductions" set amount = tramount
where batchno = new_row.batchno and empid = new_row.empid and item_no = new_row.item_no
and itemcode = new_row.itemcode
END
}
go
-请参见下面的代码-希望它可以为您提供帮助。
ALTER TRIGGER [dbo]。[deductions_update] ON [dbo]。[BATCH_DEDUCTIONS]开始更新后-添加SET NOCOUNT ON以防止出现额外的结果集-干扰SELECT语句。开启NOCOUNT;
declare @tramount numeric(12,2);
select @tramount = (new_row.factor * new_row.rate) from inserted new_row
IF (UPDATE(factor) OR UPDATE(rate))
BEGIN
update batch_deductions set amount = @tramount
from batch_deductions, inserted new_row
where batch_deductions.batchno = new_row.batchno and batch_deductions.empid = new_row.empid and batch_deductions.item_no = new_row.item_no
and batch_deductions.itemcode = new_row.itemcode
END
-- Insert statements for trigger here
结尾
去
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句