<?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>PersonalBlog &#187; delete trigger</title>
	<atom:link href="http://arimita.web.id/tag/delete-trigger/feed/" rel="self" type="application/rss+xml" />
	<link>http://arimita.web.id</link>
	<description>Just another personal weblog</description>
	<lastBuildDate>Mon, 19 Jul 2010 08:31:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TRIGGER</title>
		<link>http://arimita.web.id/2010/06/trigger/</link>
		<comments>http://arimita.web.id/2010/06/trigger/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 03:04:05 +0000</pubDate>
		<dc:creator>mythworks</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[delete trigger]]></category>
		<category><![CDATA[insert trigger]]></category>
		<category><![CDATA[privilege]]></category>
		<category><![CDATA[trigger]]></category>
		<category><![CDATA[trigger mysql]]></category>
		<category><![CDATA[update trigger]]></category>

		<guid isPermaLink="false">http://arimita.web.id/?p=242</guid>
		<description><![CDATA[Trigger means procedural code that is automatically executed in response to certain events on a particular table or view in a database. Create trigger requires the trigger privilege for the table associated with the trigger. 
TRIGGER syntax:
CREATE TRIGGER name
[BEFORE &#124; AFTER] [INSERT &#124; UPDATE &#124; DELETE]
ON tablename
FOR EACH ROW statement
BEFORE or AFTER on trigger is [...]]]></description>
			<content:encoded><![CDATA[<p>Trigger means procedural code that is automatically executed in response to certain events on a particular table or view in a database. Create trigger requires the trigger privilege for the table associated with the trigger. </p>
<p><strong>TRIGGER syntax:</strong></p>
<p>CREATE TRIGGER name<br />
[BEFORE | AFTER] [INSERT | UPDATE | DELETE]<br />
ON tablename<br />
FOR EACH ROW statement</p>
<p>BEFORE or AFTER on trigger is action time to indicate when trigger activities statement activated.<br />
INSERT or UPDATE or DELETE is event indicates the kind of statement that activates the trigger.</p>
<p>How to drop the TRIGGER ?, use DROP TRIGGER order following with table name and trigger name. And the syntax is like this:</p>
<p><strong>DROP TRIGGER tablename.triggername;</strong></p>
<p>Here they are the example case use trigger:<br />
<strong>For inserting prosess:</strong></p>
<pre class="brush: sql;">
CREATE trigger tr_input before INSERT ON user
FOR each
ROW
BEGIN
INSERT INTO master_user( id, name, pass )
VALUES (
NEW.id, NEW.name, NEW.pass
);
END$$
</pre>
<p><strong>For updating process:</strong></p>
<pre class="brush: sql;">
CREATE trigger tr_update before UPDATE ON user
FOR each
ROW
BEGIN
UPDATE master_user set id=new.id, name=new.name, pass=new.pass
where id=old.id;
END$$
</pre>
<p><strong>For deleting process:</strong></p>
<pre class="brush: sql;">
CREATE trigger tr_delete before DELETE ON user
FOR each
ROW
BEGIN
DELETE from master_user where id=old.id;
END$$
</pre>
<p>The SELECT privilege for the subject table if references to table colums occur via OLD.col_name or NEW.col_name<br />
The UPDATE privilege for the subject table columns are targets of SET NEW.col_name=value assignment.</p>
<p>Note: in this case I use two table user and master_user. And the scenario is when I input some data or something else into user which automatically updated into master_user.</p>
]]></content:encoded>
			<wfw:commentRss>http://arimita.web.id/2010/06/trigger/feed/</wfw:commentRss>
		<slash:comments>139</slash:comments>
		</item>
	</channel>
</rss>

