使用 SubSonic 2.0.3 时插入触发器失败

发布于 2024-10-21 19:55:12 字数 692 浏览 8 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2024-10-28 19:55:12

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文