<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pario TechnoBlob &#187; triggers</title>
	<atom:link href="http://pario.no/tag/triggers/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:17:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Create a mysql trigger</title>
		<link>http://pario.no/2008/10/01/create-a-mysql-trigger/</link>
		<comments>http://pario.no/2008/10/01/create-a-mysql-trigger/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 15:05:24 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://pario.no/?p=683</guid>
		<description><![CDATA[This is a short description on how you can create an easy Trigger in mysql. My trigger will insert todays date when I insert a new database record. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. Some uses for [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short description on how you can create an easy Trigger in mysql. My trigger will insert todays date when I insert a new database record.</p>
<blockquote><p>A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. Some uses for triggers are to perform checks of values to be inserted into a table or to perform calculations on values involved in an update. </p></blockquote>
<p>First you have to create a table to work with</p>
<pre>
CREATE TABLE IF NOT EXISTS `Links` (
  `Id` int(11) NOT NULL auto_increment,
  `DateInserted` date NOT NULL,
  PRIMARY KEY  (`Id`)
)</pre>
<p>Then we create the trigger that will insert todays date, curdate(), when you insert a new row</p>
<pre>
CREATE TRIGGER Links_TriggerDate BEFORE INSERT ON Links
FOR EACH
ROW
SET NEW.DateInserted = curdate( ) </pre>
<p>Triggers is a functionality that was introduced in mysql version 5.0.2<br />
To view all your triggers i mysql</p>
<pre>
mysql> show triggers;
+--------------------+--------+--------+----------------------------------+--------+---------+----------+----------------+
| Trigger            | Event  | Table  | Statement                        | Timing | Created | sql_mode | Definer        |
+--------------------+--------+--------+----------------------------------+--------+---------+----------+----------------+
| Links_TriggerDate | INSERT | Links | SET NEW.DateInserted = curdate( ) | BEFORE | NULL    |          | root@localhost |
+--------------------+--------+--------+----------------------------------+--------+---------+----------+----------------+
1 row in set (0.00 sec)
</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMDEvY3JlYXRlLWEtbXlzcWwtdHJpZ2dlci88d3B0Yj5DcmVhdGUgYSBteXNxbCB0cmlnZ2VyPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/01/create-a-mysql-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

