使用 SubSonic 2.0.3 时插入触发器失败
我目前正在使用 Subsonic 2.0.3 为现有项目生成 DataAccess。
在表上添加 sql 触发器时,亚音速在插入时开始失败,并显示错误消息
The target table 'Table Name' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
我正在使用的触发器是
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[TriggerName]
on [dbo].[TableName]
AFTER Insert
AS
BEGIN
INSERT INTO TableName
(Values)
SELECT Values
FROM Inserted
END
这似乎是因为生成的自动生成的代码是
INSERT INTO TableName
OUTPUT INSERTED.[ColumnName]
VALUES(Values)
是否有任何更改触发器或更改由生成的生成代码Subsonic 2.0.3 可以让这个工作吗?
I am currently using Subsonic 2.0.3 to generate my DataAccess for an existing project.
When adding a sql trigger on the table, subsonic starts to fail when inserting with the error message
The target table 'Table Name' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
The trigger I am using is
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[TriggerName]
on [dbo].[TableName]
AFTER Insert
AS
BEGIN
INSERT INTO TableName
(Values)
SELECT Values
FROM Inserted
END
This appears to be because the automatically generated code produced is
INSERT INTO TableName
OUTPUT INSERTED.[ColumnName]
VALUES(Values)
Is there anyway of changing the trigger or changing the generated code produced by Subsonic 2.0.3 to allow this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
M/S 说这是一个错误。您需要安装 .Net 3.5 并应用补丁:
http://support.microsoft.com/kb/961073< /a>
或
http://support.microsoft.com /hotfix/KBHotfix.aspx?kbnum=961073&kbln=en-us
查看代码,您正在插入 table2,而不是触发器正在运行的同一个表。如果它是同一张表,我想你会再次触发相同的插入触发器,并且它会带你循环。
M/S say its a bug. You need .Net 3.5 installed and apply the patch:
http://support.microsoft.com/kb/961073
or
http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=961073&kbln=en-us
Looking at the code, you are inserting into table2, not the same table the trigger is running on. If its the same table, I'd have thought you'd have fired the same insert trigger again and it'd take you round in a loop.