Error when adding record if Trigger exists on SQL DB
Error when adding record if Trigger exists on SQL DB
lm0@logic1.com.au
Posts: 11Questions: 3Answers: 0
in Editor
With editor, if I add a record to a table that has a trigger, I get the following error -
"The target table 'TableName' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause."
When I remove the trigger, it works.
I believe the SQL inset statement needs an INTO clause.
This discussion has been closed.
Answers
Wondering if you or anyone else has a solution for this? I'm running into the same issue. Thanks!
Unfortunately I have not managed to resolve this.
Hi,
Could you let me know what database type you are using please?
Allan
Sorry, should have mentioned - Sql server
Thanks for the clarification. This turns out to be fairly horrible to fix (in terms of how easy the code is to understand!). If the column could be said to be an identity column then it is as simple as appending:
But I can't say that, and don't want to restrict Editor in that way. So the fix needs to be based on this post from Microsoft.
I've committed the fix and it will be included in Editor 1.5.1, but if you want to make the change immediately, in the DataTables project find
DataBaseUtil/Sqlserver/Query.cs
and the_Prepare
method in it.Inside that method you will find an
if (_type == "insert")
block of code. Replace that with the following and then recompile:Yikes! Just to get the primary key value from an inserted row!
If you try it, let me know how you get on with it.
Regards,
Allan
Urgh - the forum is auto linking the
@
-<a href="/forums/profile/T">@ T</a>
needs to be replaced with@ T
without the spaces!Allan
Nice work Allan, that did the trick. Thank you very much!