我很难将oracle触发器转换为sql server。任何指针都非常感谢。我不知道如何更换"如果插入那么"和"如果更新那么"在sql server?
create or replace trigger tg_ap
before insert or update of strno, strfac, strfacstreet, strfacstreet2
on AP
for each row
begin
if inserting then
:new.I_stat_ind:= 'Insert';
end if;
if updating then
:new.I_stat_ind:= 'Update';
end if;
END;
答案 0 :(得分:0)
在检测操作是更新,插入还是删除时,SQLServer使它变得有点棘手。
我不会写你的触发器,但这里有一些代码可以帮助你找出当前的操作:
Create Trigger [name] on [table] Before Insert, Update As
Begin
declare @actionId int
select @actionId = case
when i.id is not null and d.id is null then 1 -- insert
when i.id is not null and d.id is not null then 2 -- update
when i.id is null and d.id is not null then 3 -- delete
end
from inserted i full join deleted d on d.id = i.id
Your Code goes here