遇到很奇怪的问题,触发器被触发时报错,终端显示"Operation abort",反复检查触发器代码,都没有找到原因,代码如下:
ALTER TRIGGER [dbo].[bi_picking_face_Trig_Vir_WH]
ON [dbo].[bi_Picking_Face]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
declare @custno varchar(12),@custprodno varchar(20),@whno varchar(16),@Wh2 varchar(16),@layer int,@depth int
if exists(select 1 from Inserted)
select @custno=custno,@custprodno=custprodno,@whno=left(whno,4) from Inserted
if exists(select 1 from Deleted)
select @custno=custno,@custprodno=custprodno,@whno=left(whno,4),@Wh2=whno,
@layer=MaxLayerNo,@depth=MaxDepthno from Deleted
if @custno is not null
begin
update bi_warehouse set flag=1 where ParentNo=@Wh2 and layerno<=@Layer and DepthNo<=@depth and flag=0
exec Gen_vir_pickingface @custno,@custprodno,@whno
end
END
最后问题解决了,将第14,15行换一下位置就可以了,求高手指教这是什么原因?只能知道原因所在,下次才不会再犯这样的错误
------解决方案--------------------
你原来是先exec再update?
------解决方案--------------------
执行顺序都不一样 当然不一样了。