<?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 To Use Triggers to Track Changes in MySQL</title>
	<atom:link href="http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/</link>
	<description></description>
	<lastBuildDate>Tue, 31 Aug 2010 09:05:10 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Ali</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15217</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Sat, 01 May 2010 16:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15217</guid>
		<description>great to have found this site.  I have used all search engines to find someone trying to update a table based on input changes.  My issue was:&lt;br&gt;1- keep loading a table everyday.  &lt;br&gt;2- data rows that is to load the table are repetitive.  Not all of them change in value&lt;br&gt;3- once i use insert .... on duplicate key update .  The table updates with the new information irrespective whether the values are equal or not.  I am not sure why, but I have a timestamp field among the fields.  And, i am passing a current_timestamp() function in the insert statement.  This is needed to timestamp new records, and timestamp the duplicate key records if any of their values differ. &lt;br&gt;What I ended up getting, an updated timestamp that is always current.  I lose track whether a real change exist in the values themselves. I think timestamp fields update with a timestamp irrespective whether other values change, that&#039;s because the timestamp field by itself changed.  Enough to execute the update.  This is the first caveat.  What I really want is to leave the row unchanged based on the values i am checking and reset the timestamp to the old one.&lt;br&gt;so, the trigger helped me achieve that by putting an if then else statement.  Similar to the above, yet introduced the else and SET new.timestamp = old.timestamp, new.counter=old.counter.  My if checks all the values that might have changes with &lt;br&gt;IF NEW.VALUE&lt;&gt;OLD.VALUE OR NEW.VALUE_1 &lt;&gt; OLD.VALUE_1 for all values ..., &lt;br&gt;THEN INSERT INTO history_table SELECT * FROM table WHERE identifiers are =.. &lt;br&gt;(The OLD.* didn&#039;t work.)&lt;br&gt;ELSE SET NEW.TIMESTAMP=OLD.TIMESTAMP, NEW.COUNTER=OLD.COUNTER&lt;br&gt;&lt;br&gt;That did the magic, because it neutralized the new buffer to the old buffer and the update needn&#039;t to execute.&lt;br&gt;&lt;br&gt;Hope that helps those who have the same issue.</description>
		<content:encoded><![CDATA[<p>great to have found this site.  I have used all search engines to find someone trying to update a table based on input changes.  My issue was:<br />1- keep loading a table everyday.  <br />2- data rows that is to load the table are repetitive.  Not all of them change in value<br />3- once i use insert &#8230;. on duplicate key update .  The table updates with the new information irrespective whether the values are equal or not.  I am not sure why, but I have a timestamp field among the fields.  And, i am passing a current_timestamp() function in the insert statement.  This is needed to timestamp new records, and timestamp the duplicate key records if any of their values differ. <br />What I ended up getting, an updated timestamp that is always current.  I lose track whether a real change exist in the values themselves. I think timestamp fields update with a timestamp irrespective whether other values change, that&#39;s because the timestamp field by itself changed.  Enough to execute the update.  This is the first caveat.  What I really want is to leave the row unchanged based on the values i am checking and reset the timestamp to the old one.<br />so, the trigger helped me achieve that by putting an if then else statement.  Similar to the above, yet introduced the else and SET new.timestamp = old.timestamp, new.counter=old.counter.  My if checks all the values that might have changes with <br />IF NEW.VALUE&lt;&gt;OLD.VALUE OR NEW.VALUE_1 &lt;&gt; OLD.VALUE_1 for all values &#8230;, <br />THEN INSERT INTO history_table SELECT * FROM table WHERE identifiers are =.. <br />(The OLD.* didn&#39;t work.)<br />ELSE SET NEW.TIMESTAMP=OLD.TIMESTAMP, NEW.COUNTER=OLD.COUNTER</p>
<p>That did the magic, because it neutralized the new buffer to the old buffer and the update needn&#39;t to execute.</p>
<p>Hope that helps those who have the same issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15208</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Fri, 22 Jan 2010 10:58:24 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15208</guid>
		<description>perfect... exactly what I was looking for.</description>
		<content:encoded><![CDATA[<p>perfect&#8230; exactly what I was looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phani Kumar Varanasi</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15202</link>
		<dc:creator>Phani Kumar Varanasi</dc:creator>
		<pubDate>Thu, 12 Nov 2009 04:24:16 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15202</guid>
		<description>Yeah Dear, the concept you entered is so helpful, well good work.</description>
		<content:encoded><![CDATA[<p>Yeah Dear, the concept you entered is so helpful, well good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: abhinavzone</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15188</link>
		<dc:creator>abhinavzone</dc:creator>
		<pubDate>Wed, 29 Jul 2009 16:57:23 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15188</guid>
		<description>Thank you very much!!! it saved my day</description>
		<content:encoded><![CDATA[<p>Thank you very much!!! it saved my day</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mysql Trigger Tutorial and Tools &#124; Learning On Demand</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15174</link>
		<dc:creator>Mysql Trigger Tutorial and Tools &#124; Learning On Demand</dc:creator>
		<pubDate>Thu, 18 Jun 2009 15:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15174</guid>
		<description>[...] How To Use Triggers to Track Changes in MySQL, more advance sample. [...]</description>
		<content:encoded><![CDATA[<p>[...] How To Use Triggers to Track Changes in MySQL, more advance sample. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Allard</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15152</link>
		<dc:creator>Greg Allard</dc:creator>
		<pubDate>Mon, 20 Apr 2009 16:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15152</guid>
		<description>I don&#039;t think there is anyway to do it in the database, but you can still put the logic in your application. If you are using django, there are signals that will help get that done. &lt;a href=&quot;http://docs.djangoproject.com/en/1.0/topics/signals/&quot; rel=&quot;nofollow&quot;&gt;http://docs.djangoproject.com/en/1.0/topics/sig...&lt;/a&gt; If you aren&#039;t then you will need to program it into your project in some other way.</description>
		<content:encoded><![CDATA[<p>I don&#39;t think there is anyway to do it in the database, but you can still put the logic in your application. If you are using django, there are signals that will help get that done. <a href="http://docs.djangoproject.com/en/1.0/topics/signals/" rel="nofollow"></a><a href="http://docs.djangoproject.com/en/1.0/topics/sig.." rel="nofollow">http://docs.djangoproject.com/en/1.0/topics/sig..</a>. If you aren&#39;t then you will need to program it into your project in some other way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15151</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Mon, 20 Apr 2009 16:03:18 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15151</guid>
		<description>Does any way work as trigger in mysql 4.1? I know that triggers is supported from mysql 5.0 &lt;br&gt;thanks for help</description>
		<content:encoded><![CDATA[<p>Does any way work as trigger in mysql 4.1? I know that triggers is supported from mysql 5.0 <br />thanks for help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IT Tutorials &#187; Mysql Trigger Tutorial and Tools</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15138</link>
		<dc:creator>IT Tutorials &#187; Mysql Trigger Tutorial and Tools</dc:creator>
		<pubDate>Mon, 16 Mar 2009 09:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15138</guid>
		<description>[...] How To Use Triggers to Track Changes in MySQL, more advance sample. [...]</description>
		<content:encoded><![CDATA[<p>[...] How To Use Triggers to Track Changes in MySQL, more advance sample. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Allard</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15101</link>
		<dc:creator>Greg Allard</dc:creator>
		<pubDate>Fri, 31 Oct 2008 17:50:08 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15101</guid>
		<description>OLD and NEW are used on UPDATE triggers. OLD.col_names will access the data that is in the row of the database before the UPDATE query runs and NEW.col_names will access the data that the row will be updated to. &lt;br&gt;&lt;br&gt;IF OLD.first_name != NEW.first_name&lt;br&gt;&lt;br&gt;That checks if the UPDATE query is changing the information for first_name.</description>
		<content:encoded><![CDATA[<p>OLD and NEW are used on UPDATE triggers. OLD.col_names will access the data that is in the row of the database before the UPDATE query runs and NEW.col_names will access the data that the row will be updated to. </p>
<p>IF OLD.first_name != NEW.first_name</p>
<p>That checks if the UPDATE query is changing the information for first_name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mysqlearner</title>
		<link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/comment-page-1/#comment-15100</link>
		<dc:creator>mysqlearner</dc:creator>
		<pubDate>Fri, 31 Oct 2008 14:33:53 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=36#comment-15100</guid>
		<description>hi ,&lt;br&gt;please can u explain what is &lt;br&gt;OLD.first_name != NEW.first_name&lt;br&gt;are they table names?&lt;br&gt;I need to write  atrigger to get the changed row and also how do i get the same query either insert,update or delete.&lt;br&gt;thanks in advance</description>
		<content:encoded><![CDATA[<p>hi ,<br />please can u explain what is <br />OLD.first_name != NEW.first_name<br />are they table names?<br />I need to write  atrigger to get the changed row and also how do i get the same query either insert,update or delete.<br />thanks in advance</p>
]]></content:encoded>
	</item>
</channel>
</rss>
