<?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>Techno Oracle &#187; Triggers in oracle</title>
	<atom:link href="http://www.technooracle.com/oracle-tutorials/category/oracle-plsql/triggers-in-oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.technooracle.com</link>
	<description>Oracle information centre</description>
	<lastBuildDate>Tue, 17 Apr 2012 12:07:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Dropping Triggers in Oracle</title>
		<link>http://www.technooracle.com/oracle-tutorials/dropping-triggers-in-oracle/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/dropping-triggers-in-oracle/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 18:05:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Triggers in oracle]]></category>
		<category><![CDATA[DROP ANY TRIGGER privilage]]></category>
		<category><![CDATA[DROP TRIGGER]]></category>
		<category><![CDATA[DROP TRIGGER Example]]></category>
		<category><![CDATA[Dropping trigger]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=290</guid>
		<description><![CDATA[Triggers may be dropped via the drop trigger command. In order to drop a trigger, you must either own the trigger or have the DROP ANY TRIGGER system privilege. Syntax: DROP TRIGGER trigger_name; Example: CREATE OR REPLACE TRIGGER EMP_MONDAY BEFORE INSERT OR UPDATE OR DELETE ON EMP BEGIN IF RTRIM(UPPER(TO_CHAR(SYSDATE,'DAY')))='MONDAY' THEN RAISE_APPLICATION_ERROR (-20022,'NO OPERARTION CAN [...]]]></description>
			<content:encoded><![CDATA[<p>Triggers may be dropped via the drop trigger command. In order to drop a trigger, you must either own the trigger or have the <strong>DROP ANY TRIGGER </strong>system privilege.</p>
<p><strong>Syntax:</strong></p>
<p>DROP TRIGGER trigger_name;</p>
<p><strong>Example:</strong></p>
<pre>CREATE OR REPLACE TRIGGER EMP_MONDAY</pre>
<pre>BEFORE INSERT OR UPDATE OR DELETE ON EMP</pre>
<pre>BEGIN</pre>
<pre style="padding-left: 30px;">IF RTRIM(UPPER(TO_CHAR(SYSDATE,'DAY')))='MONDAY' THEN</pre>
<pre style="padding-left: 60px;">RAISE_APPLICATION_ERROR
(-20022,'NO OPERARTION CAN BE PERFORMED ON MONDAY');</pre>
<pre style="padding-left: 30px;">END IF;</pre>
<pre>END;</pre>
<h3><span style="color: #000080;">Dropping Trigger</span></h3>
<pre>DROP TRIGGER REC_CHECK;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/dropping-triggers-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling and Disabling Triggers</title>
		<link>http://www.technooracle.com/oracle-tutorials/enabling-and-disabling-triggers/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/enabling-and-disabling-triggers/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 17:51:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Triggers in oracle]]></category>
		<category><![CDATA[disable trigger]]></category>
		<category><![CDATA[disabling Trigger]]></category>
		<category><![CDATA[Enable trigger]]></category>
		<category><![CDATA[enabling Trigger]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=288</guid>
		<description><![CDATA[When a trigger is created it is automatically enabled and is triggered whenever the triggering command and the execution command is true.An enabled trigger executes the trigger body if the triggering statement is issued. To disable the execution use the ALTER TRIGGER command with the DISABLE clause. A disable trigger does not execute the trigger [...]]]></description>
			<content:encoded><![CDATA[<p>When a trigger is created it is automatically enabled and is triggered whenever the triggering command and the execution command is true.An enabled trigger executes the trigger body if the triggering statement is issued. To disable the execution use the <strong>ALTER TRIGGER</strong> command with the <strong>DISABLE</strong> clause. A disable trigger does not execute the trigger body even if the triggering statement is issued.</p>
<p>We can disable / enable the trigger by the following syntax:</p>
<p><strong>ALTER TRIGGER &lt;trigger name&gt; DISABLE / ENABLE</strong></p>
<p><strong>Example</strong></p>
<pre>CREATE OR REPLACE TRIGGER UPDATE_CHECK BEFORE UPDATE ON EMP
FOR EACH ROW
</pre>
<pre>BEGIN
</pre>
<pre style="padding-left: 30px;">IF :NEW.SAL&lt;:OLD.SAL THEN
</pre>
<pre style="padding-left: 60px;">RAISE_APPLICATION_ERROR(-20000,'NEW SALARY
CANNOT BE LESS THAN OLD SALARY');</pre>
<pre style="padding-left: 30px;">END IF;</pre>
<pre>END;
</pre>
<h3><span style="color: #000080;">Enabling Trigger</span></h3>
<pre>SQL&gt;ALTER TRIGGER <strong>UPDATE_CHECK DISABLE;

Trigger Disabled;

</strong>
<h3><span style="color: #000080;">Disabling Trigger</span></h3>
</pre>
<pre>SQL&gt;ALTER TRIGGER <strong></strong><strong>UPDATE_CHECK ENABLE;

Trigger Enabled;

</strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/enabling-and-disabling-triggers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error Handling in Triggers</title>
		<link>http://www.technooracle.com/oracle-tutorials/error-handling-in-trigger/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/error-handling-in-trigger/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 17:40:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Triggers in oracle]]></category>
		<category><![CDATA[error handling in trigger]]></category>
		<category><![CDATA[RAISE_APPLICATION_ERROR]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=287</guid>
		<description><![CDATA[The Oracle engine provides a procedure named raise_appliation_error that allows programmers to issue user-defined error messages. Syntax: RAISE_APPLICATION_ERROR (error_number, message); Here: error_number It is a negative integer in the range-20000 to –20999 Message It is a character string up to 2048 bytes in length This procedure terminates procedure execution, rolls back any effects of the [...]]]></description>
			<content:encoded><![CDATA[<p>The Oracle engine provides a procedure named raise_appliation_error that allows programmers to issue user-defined error messages.</p>
<p>Syntax:<br />
<strong>RAISE_APPLICATION_ERROR (error_number, message);</strong></p>
<p>Here:<br />
<strong>error_number</strong><br />
It is a negative integer in the range-20000 to –20999</p>
<p><strong>Message</strong><br />
It is a character string up to 2048 bytes in length</p>
<p>This procedure terminates procedure execution, rolls back any effects of the procedure, and returns a user-specified error number and message. Following example makes use of the <strong>RAISE_APPLICAION_ERROR</strong>.</p>
<p>To Create a trigger so that no operation can be performed on emp table<br />
on Monday.</p>
<p>Solution:</p>
<pre>CREATE OR REPLACE TRIGGER EMP_MONDAY</pre>
<pre>BEFORE INSERT OR UPDATE OR DELETE ON EMP</pre>
<pre>BEGIN</pre>
<pre style="padding-left: 30px;">IF RTRIM(UPPER(TO_CHAR(SYSDATE,'DAY')))='MONDAY' THEN</pre>
<pre style="padding-left: 90px;">RAISE_APPLICATION_ERROR
(-20022,'NO OPERARTION CAN BE PERFORMED ON MONDAY');</pre>
<pre style="padding-left: 30px;">END IF;</pre>
<pre>END;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/error-handling-in-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Types of Triggers</title>
		<link>http://www.technooracle.com/oracle-tutorials/types-of-triggers-in-oracle-plsql/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/types-of-triggers-in-oracle-plsql/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:12:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Triggers in oracle]]></category>
		<category><![CDATA[After Triggers]]></category>
		<category><![CDATA[Before Triggers]]></category>
		<category><![CDATA[INSTEAD OF trigger]]></category>
		<category><![CDATA[Row Level Triggers]]></category>
		<category><![CDATA[Statement Level Triggers]]></category>
		<category><![CDATA[triggers in oracle]]></category>
		<category><![CDATA[Types of Triggers]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=282</guid>
		<description><![CDATA[A trigger’s type is defined by the type of triggering transaction and by the level at which the trigger is executed. Oracle has the following types of triggers depending on the different applications: Row Level Triggers Statement Level Triggers Before Triggers After Triggers Here is a brief description about above triggers: Row Level Triggers Row [...]]]></description>
			<content:encoded><![CDATA[<p>A trigger’s type is defined by the type of triggering transaction and by the level at which the trigger is executed. Oracle has the following types of triggers depending on the different applications:</p>
<ul>
<li><strong><span style="color: #000080;"> Row Level Triggers</span></strong></li>
<li><strong><span style="color: #000080;"> Statement Level Triggers<br />
</span></strong></li>
<li><strong><span style="color: #000080;"> Before Triggers<br />
</span></strong></li>
<li><strong><span style="color: #000080;"> After Triggers</span></strong></li>
</ul>
<p>Here is a brief description about above triggers:</p>
<h2><span style="color: #000080;">Row Level Triggers</span></h2>
<p>Row level triggers execute once for each row in a transaction. The commands of row level triggers are executed on all rows that are affected by the command that enables the trigger. For example, if an UPDATE statement updates multiple rows of a table, a row trigger is fired once for each row affected by the UPDATE statement. If the triggering statement affects no rows, the trigger is not executed at all. Row level triggers are created using the FOR EACH ROW clause in the CREATE TRIGGER command.<br />
<span id="more-282"></span></p>
<h2><span style="color: #000080;">Statement Level Triggers</span></h2>
<p>Statement level triggers are triggered only once for each transaction. For example when an UPDATE command update 15 rows, the commands contained in the trigger are executed only once, and not with every processed row. Statement level trigger are the default types of trigger created via the CREATE TRIGGER command.</p>
<h2><span style="color: #000080;">Before  Trigger</span></h2>
<p>Since triggers are executed by events, they may be set to occur immediately before or after those events. When a trigger is defined, you can specify whether the trigger must occur before or after the triggering event i.e. INSERT, UPDATE, or DELETE commands.</p>
<p>BEFORE trigger execute the trigger action before the triggering statement. These types of triggers are commonly used in the following situation:</p>
<ul>
<li> BEFORE triggers are used when the trigger action should determine whether or not the triggering statement should be allowed to complete. By using a BEFORE trigger, you can eliminate unnecessary processing of the triggering statement. For example: To prevent deletion on Sunday, for this we have to use Statement level before trigger on DELETE statement.</li>
<li> BEFORE triggers are used to derive specific column values before completing a triggering INSERT or UPDATE statement.</li>
</ul>
<h2><span style="color: #000080;">After Trigger</span></h2>
<p>AFTER trigger executes the trigger action after the triggering statement is executed. AFTER triggers are used when you want the triggering statement to complete before executing the trigger action.</p>
<p>For example: To perform cascade delete operation, it means that user delete the record fro one table, but the corresponding records in other tables are delete automatically by a trigger which fired after the execution of delete statement issued by the user.</p>
<p>When combining the different types of triggering actions, there are mainly 12 possible valid trigger types available to us. The possible configurations are:</p>
<ul>
<li><strong><span style="color: #000080;">BEFORE INSERT row</span></strong></li>
<li><strong><span style="color: #000080;"> BEFORE INSERT statement</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER INSERT row</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER INSERT statement</span></strong></li>
<li><strong><span style="color: #000080;"> BEFORE UPDATE row</span></strong></li>
<li><strong><span style="color: #000080;"> BEFORE UPDATE statement</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER UPDATE Row</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER UPDATE statement</span></strong></li>
<li><strong><span style="color: #000080;"> BEFORE DELETE row</span></strong></li>
<li><strong><span style="color: #000080;"> BEFORE DELETE statement</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER DELETE row</span></strong></li>
<li><strong><span style="color: #000080;"> AFTER DELETE statement</span></strong></li>
</ul>
<table style="height: 134px;" border="1" cellspacing="0" cellpadding="0" width="494">
<tbody>
<tr>
<td width="213" valign="top"><strong>Name</strong></td>
<td width="213" valign="top"><strong>Statement Level</strong></td>
<td width="213" valign="top"><strong>Row Level</strong></td>
</tr>
<tr>
<td width="213" valign="top"><strong>BEFORE option</strong></td>
<td width="213" valign="top"><strong>Oracle fires trigger only once   before executing the triggering statement</strong></td>
<td width="213" valign="top"><strong>Oracle fires trigger before   modifying each row affected by the triggering statement</strong></td>
</tr>
<tr>
<td width="213" valign="top"><strong>AFTER option</strong></td>
<td width="213" valign="top"><strong>Oracle fires trigger only once   before executing the triggering statement</strong></td>
<td width="213" valign="top"><strong>Oracle fires trigger before   modifying each row affected by the triggering statement</strong></td>
</tr>
</tbody>
</table>
<h2><span style="color: #000080;">Instead of Trigger</span></h2>
<p>These Triggers are Defined on a View rather than a table.You can use <strong>INSTEAD OF TRIGGER </strong>to tell oracle what to do instead of  performing actions that invoked the  trigger.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/types-of-triggers-in-oracle-plsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Triggers in Oracle PL/SQL</title>
		<link>http://www.technooracle.com/oracle-tutorials/triggers-in-oracle-plsql/</link>
		<comments>http://www.technooracle.com/oracle-tutorials/triggers-in-oracle-plsql/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 17:35:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Triggers in oracle]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[pl sql]]></category>
		<category><![CDATA[trigger in database]]></category>
		<category><![CDATA[trigger in oracle]]></category>
		<category><![CDATA[trigger in pl sql]]></category>
		<category><![CDATA[trigger in sql]]></category>
		<category><![CDATA[trigger oracle]]></category>
		<category><![CDATA[Triggers]]></category>
		<category><![CDATA[triggers in oracle]]></category>
		<category><![CDATA[triggers in sql]]></category>
		<category><![CDATA[what is trigger in oracle]]></category>
		<category><![CDATA[what is trigger in sql]]></category>

		<guid isPermaLink="false">http://www.technooracle.com/?p=279</guid>
		<description><![CDATA[A database trigger is a stored procedure that is fired when an INSERT,UPDATE, or DELETE statements is issued against the associate table.The name trigger is appropriate, as these are triggered (fired) whenever the above-mentioned commands are executed. A trigger defines an action the database should take when some database related event occurs. A trigger can [...]]]></description>
			<content:encoded><![CDATA[<p>A database trigger is a stored procedure that is fired when an INSERT,UPDATE, or DELETE statements is issued against the associate table.The name trigger is appropriate, as these are triggered (fired) whenever the above-mentioned commands are executed. A trigger defines an action the database should take when some database related event occurs. A trigger can include SQL and PL/SQL statements to executor as a unit and can invoke other stored procedures. Triggers may use to provide referential integrity, to enforce complex business rules, or to audit changes to data. The code within a trigger, called the trigger body is made up of PL/SQL blocks.</p>
<p>A trigger is automatically executed without any action required by the user. A stored procedure on other hand needs to be explicitly invoked.This is the main difference between a trigger and a stored procedure.<br />
<span id="more-279"></span></p>
<h2><span style="color: #000080;">Parts of a Trigger</span></h2>
<p>A database trigger has three parts:</p>
<ul>
<li> Triggering event or Statement.</li>
<li> Trigger constraint (Optinal).</li>
<li> Trigger action.</li>
</ul>
<p><strong><span style="color: #000080;">Triggering Event or Statement</span></strong></p>
<p>A triggering event or statement is the SQL statement that causes a trigger<br />
to be fired. A triggering event can be an INSERT, UPDATE, or<br />
DELETE statement for a specific table.</p>
<h3><span style="color: #000080;">Trigger Constraint or Restriction</span></h3>
<p>A trigger restriction specifies a Boolean (logical) expression that must<br />
be TRUE for the trigger to fire. The trigger action s not executed if the<br />
trigger restriction evaluates to FALSE. A trigger restriction is an option<br />
available for triggers that are fired for each row. Its function is to<br />
conditionally control the execution of a trigger. A trigger restriction is<br />
specified using a WHEN clause. It is an optional part of trigger.</p>
<h3><span style="color: #000080;">Trigger Action</span></h3>
<p>A trigger action is the procedure (PL/SQL block) that contains the<br />
SQL statements and PL/SQL code to be executed when a triggering<br />
statement is issued and the trigger restriction evaluates to TRUE.</p>
<h2><span style="color: #000080;">Syntax For Creating Trigger</span><strong><br />
</strong></h2>
<p><strong>CREATE [OR REPLACE] TRIGGER trigger_name<br />
{BEFORE|AFTER}<br />
{|DELETE|[OR]INSERT|[OR]UPDATE [OF column_name...]<br />
ON table_name<br />
</strong></p>
<p><strong>[REFERENCING {OLD as old,NEW as new}]<br />
[FOR EACH ROW[WHEN condition]</strong></p>
<p><strong>DECLARE </strong></p>
<p><strong> Variable decalration;<br />
Constant declaration;</strong></p>
<p><strong>BEGIN<br />
</strong></p>
<p><strong> PL/SQL subprogram body;</strong> <strong><br />
</strong></p>
<p><strong>[EXCEPTION<br />
exception PL/SQL block;]<br />
END;<br />
</strong></p>
<p>Here:</p>
<p><strong>REFERENCING:</strong> Specified correlation names. The user could use the Correlation names in the PL/SQL block and <strong>WHEN</strong> clause of a row trigger to refer specifically to old and new values of the current row. The default correlation names are <strong>OLD</strong> and <strong>NEW</strong>. If the row is associated with a table named <strong>OLD</strong> or <strong>NEW</strong>, this clause can be used to specify different names to avoid confusion between the table name and the correlation name.</p>
<p><strong>WHEN</strong>: Specifies the trigger restriction. This condition has to be satisfied to fire the trigger. This condition can be specified for the <strong>ROW TRIGGER</strong>.</p>
<h2><span style="color: #000080;">Use of Database Triggers</span></h2>
<p>Database triggers can be used for the following purposes:</p>
<ul>
<li> To derive column values automatically.</li>
<li> To enforce complex integrity constraints.</li>
<li> To enforce complex business rules.</li>
<li> To customize complex security authorizations.</li>
<li> To maintain replicate tables.</li>
<li> To audit data modifications.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.technooracle.com/oracle-tutorials/triggers-in-oracle-plsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

