Failing insert trigger when using 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 QUOT开发者_开发百科ED_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?
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.
精彩评论