<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How dumb the instead of triggers on MS SQL are???</title>
	<atom:link href="http://blog.cincura.net/230777-how-dumb-the-instead-of-triggers-on-ms-sql-are/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cincura.net/230777-how-dumb-the-instead-of-triggers-on-ms-sql-are/</link>
	<description>Taking something that can&#039;t be done, and then doing it.</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:02:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Alibek Kulzhabayev</title>
		<link>http://blog.cincura.net/230777-how-dumb-the-instead-of-triggers-on-ms-sql-are/#comment-3466</link>
		<dc:creator>Alibek Kulzhabayev</dc:creator>
		<pubDate>Fri, 16 Jul 2010 08:16:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230777#comment-3466</guid>
		<description>the reason is instead of trigger works just with views that&#039;s all.</description>
		<content:encoded><![CDATA[<p>the reason is instead of trigger works just with views that&#8217;s all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cincura.net</title>
		<link>http://blog.cincura.net/230777-how-dumb-the-instead-of-triggers-on-ms-sql-are/#comment-1692</link>
		<dc:creator>cincura.net</dc:creator>
		<pubDate>Sat, 25 Jul 2009 09:18:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230777#comment-1692</guid>
		<description>I think, that cascade delete in FK constraint and instead of trigger on table are two not related pieces.

Let&#039;s assume that my FK column allows null values. Then I can simply in trigger set it to null and the master delete operation succeeds (yes, I know I can do it directly with constraint). This scenario is perfectly valid and I&#039;m still unable to create it.

I still think it&#039;s wrong, but your comment made me realize something. I&#039;m probably looking at the problem from more higher/design level. I see trigger as action started by database *instead of* the real operation. So the database at some level still thinks it&#039;s performing delete, but the lower level is simply throwing it away and running the trigger. Nothing more, nothing less. This architecture in my mind probably comes from the before/after trigger designs in other databases, just converted to instead of thinking.

It&#039;s same with &quot;potential&quot; circular cascade updates/deletes. Yes I know the total shit can happen, but I&#039;m developer, I know what I want (and if not, it&#039;s my fault, I should read something about it).

Maybe the MSSQL is trying to keep me in safe boundaries too much. :)</description>
		<content:encoded><![CDATA[<p>I think, that cascade delete in FK constraint and instead of trigger on table are two not related pieces.</p>
<p>Let&#8217;s assume that my FK column allows null values. Then I can simply in trigger set it to null and the master delete operation succeeds (yes, I know I can do it directly with constraint). This scenario is perfectly valid and I&#8217;m still unable to create it.</p>
<p>I still think it&#8217;s wrong, but your comment made me realize something. I&#8217;m probably looking at the problem from more higher/design level. I see trigger as action started by database *instead of* the real operation. So the database at some level still thinks it&#8217;s performing delete, but the lower level is simply throwing it away and running the trigger. Nothing more, nothing less. This architecture in my mind probably comes from the before/after trigger designs in other databases, just converted to instead of thinking.</p>
<p>It&#8217;s same with &#8220;potential&#8221; circular cascade updates/deletes. Yes I know the total shit can happen, but I&#8217;m developer, I know what I want (and if not, it&#8217;s my fault, I should read something about it).</p>
<p>Maybe the MSSQL is trying to keep me in safe boundaries too much. <img src='http://blog.cincura.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petr Lazecky</title>
		<link>http://blog.cincura.net/230777-how-dumb-the-instead-of-triggers-on-ms-sql-are/#comment-1689</link>
		<dc:creator>Petr Lazecky</dc:creator>
		<pubDate>Fri, 24 Jul 2009 17:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230777#comment-1689</guid>
		<description>OK, so let&#039;s assume that this will be possible. What behaviour will you expect? You are saying that &quot;would be willing to accept the limitation when I’ll be doing there some master table manipulation&quot;. Actually you do. Your instead of trigger above is effectivelly swallowing delete in detail table meaning that if delete in master will be allowed in this case you will get orphan records in detail table on you will break data consistency.

From my perspective this behaviour is quite logical as I see these two constrains contradicting each other. You either want to redirect detele operation in INSTEAD OF trigger to some other logic (usually to replace original DELETE operation with UPDATE) or you want CASCADE DELETE. If you do not want to redirect DELETE operation to some other logic (and cancelling original DELETE) you would use normal TRIGGER ON DELETE.</description>
		<content:encoded><![CDATA[<p>OK, so let&#8217;s assume that this will be possible. What behaviour will you expect? You are saying that &#8220;would be willing to accept the limitation when I’ll be doing there some master table manipulation&#8221;. Actually you do. Your instead of trigger above is effectivelly swallowing delete in detail table meaning that if delete in master will be allowed in this case you will get orphan records in detail table on you will break data consistency.</p>
<p>From my perspective this behaviour is quite logical as I see these two constrains contradicting each other. You either want to redirect detele operation in INSTEAD OF trigger to some other logic (usually to replace original DELETE operation with UPDATE) or you want CASCADE DELETE. If you do not want to redirect DELETE operation to some other logic (and cancelling original DELETE) you would use normal TRIGGER ON DELETE.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

