Ignore inserts/updates/delete from within the function that's using the SQL trigger #840
Replies: 1 comment
-
Unfortunately, that isn't something that we support at this time. This seems like a very useful thing to have though, so I opened an issue to track it - #852 You can follow that for any updates, and if you have anything else to add please do so! Thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I've written an Azure function using the SQL trigger to process records that have been inserted into a table. When I am finished with the processing, I need to update the record that was processed to indicate it was successfully processed. Currently I am using a DbContext and calling ExecuteSqlInterpolated to update the underlying record from within the function, using the ID of the record that was processed via the triggered function. However, this results in another change to the DB that causes the trigger to fire again. When the function runs, I can filter the
changes
list to only include inserts, like this:changes.Any(m => m.Operation == SqlChangeOperation.Insert)
That way I skip processing for those, but it is an unnecessary call to the function nonetheless. Is there a way to ignore updates (or inserts or delete for that matter) that are made inside the function, either by not tracking them, or usingCHANGE_TRACKING_CONTEXT
in theUPDATE
statement and ignoring that context in the queries in this library's classSqlTableChangeMonitor
? This would be similar to what's described here https://www.mssqltips.com/sqlservertip/6521/sync-sql-server-change-tracking-tables-without-changing-data/Thanks!
Beta Was this translation helpful? Give feedback.
All reactions