<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PROGRAMMER DESK &#187; PL/SQL Pragma</title>
	<atom:link href="http://vinayhatwal.wordpress.com/category/oracle-10g/plsql-pragma/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinayhatwal.wordpress.com</link>
	<description>Accept Changes To Develop Good Solutions</description>
	<lastBuildDate>Sun, 02 Aug 2009 10:34:20 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='vinayhatwal.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/fddfa1cd68a112c3fb6eca04033658e3?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PROGRAMMER DESK &#187; PL/SQL Pragma</title>
		<link>http://vinayhatwal.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vinayhatwal.wordpress.com/osd.xml" title="PROGRAMMER DESK" />
		<item>
		<title>PL/SQL Pragma</title>
		<link>http://vinayhatwal.wordpress.com/2008/08/25/plsql-pragma/</link>
		<comments>http://vinayhatwal.wordpress.com/2008/08/25/plsql-pragma/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 04:53:38 +0000</pubDate>
		<dc:creator>vinayhatwal</dc:creator>
				<category><![CDATA[PL/SQL Pragma]]></category>
		<category><![CDATA[Oracle Pragma]]></category>
		<category><![CDATA[Pragma]]></category>
		<category><![CDATA[Vinayhatwal]]></category>

		<guid isPermaLink="false">http://vinayhatwal.wordpress.com/?p=94</guid>
		<description><![CDATA[PL/SQL Pragma
 
Pragma – 
Pragma is nothing but the compiler directive which simply conveys the information to the compiler. Because the Pragma is the complier directive so the processed at compile time not run time.
 
AUTONOMOUS_TRANSACTION Pragma
 
AUTONOMOUS_TRANSACTION Pragma instructs to the compiler to mark a transaction autonomous, or you can independent. An Autonomous transaction is the independent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=94&subd=vinayhatwal&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="text-align:center;margin:0;" align="center"><strong><span style="font-size:20pt;color:#ff0000;font-family:&quot;">PL/SQL Pragma</span></strong></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Pragma – </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Pragma is nothing but the compiler directive which simply conveys the information to the compiler. Because the Pragma is the complier directive so the processed at compile time not run time.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">AUTONOMOUS_TRANSACTION Pragma</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">AUTONOMOUS_TRANSACTION Pragma instructs to the compiler to mark a transaction autonomous, or you can independent. An Autonomous transaction is the independent transactions which runs by the another transaction or main transaction. An autonomous transaction suspends the main transaction in which they are calling, do the SQL statements, commit or rollback then according to the user’s need then after completing resume the main transaction. </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Commit or Rollback only works for the statements which are inside the calling transaction so that they are independent to the main transaction.<span>  </span>It does not share any lock, resources and any commit or rollback dependence with the main transaction. </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">If you are using it with the triggers then unlike normal triggers these autonomous triggers can perform the DDL operation by using the native dynamic SQL. If you set the isolation level of the main transaction to SERIALIZABLE, as follows, changes made by its autonomous transactions are not visible to the main transaction hen it resumes:</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">See, if the main transaction perform the rollback at any save point after the autonomous block then it will not effect the changes made by the autonomous transaction because the autonomous transaction is fully independent from it’s main transaction.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Limitations –</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">You can not use the Pragma in the Subprogram that resides in the package. You can only user Pragma in the individual subprogram. You can use Pragma anywhere in the declarative part of the PL/SQL Block but always use it on the top position in the declarative part for readability.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Consider the following block of code –</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Main Procedure (Caller Procedure) </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">create</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">or</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">replace</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">procedure</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> MainProc </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">as</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">update</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#808000;font-family:&quot;">myemployeemaster</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">set</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;vinny&#8217;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">where</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Ashish&#8217;</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span>SimpleProc</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>      </span></span><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Calling an ordinary procedure </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">rollback;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">exception</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">then</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Procedure without Autonomous Transaction Block (Calee Procedure)<span>   </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">create</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">or</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">replace</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">procedure</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> SimpleProc </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">as</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">update</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#808000;font-family:&quot;">myemployeemaster</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">set</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Vikram&#8217;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">where</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Pawan Kumar&#8217;</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">commit;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">exception</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">then</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Explanation- </span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">In the above example the MainProc updates the MyEmployeeMaster table and update the name<span>  </span>Ashish to Vinny. But After a SimpleProc call the procedure want to rollback his transaction. But when the SimpleProc procedure called the control of MaiProc goes into the SiimpleProc. In the SimpleProc MyEmployeeMaster is again updating the name Pawan Kumar with the name Vikram and then it commit its transactions. After the completing of SimpleProc the control again goes to the MainProc Procedure and then want to rollback all the changes done by it. But See, The SimpleProc Transaction has already committed the whole transactions. See the effect in the table MyEmployeeMaster, You will see that all the transactions are committed even of the MainProc Procedure.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">It happened because the in the both procedure only single transaction is working, both are the part of a single transaction. So If you want to work on different Procedure for different transactions then you can use the Autonomous_Transaction Pragma. This Pragma will direct to the compiler for doing the different Transaction for the block where it defined.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Now the following Block of code is modified by using Autonomous_Transaction Pragma –</span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Main Procedure (Caller Procedure) </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">create</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">or</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">replace</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">procedure</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> MainProc </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">as</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">update</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#808000;font-family:&quot;">myemployeemaster</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">set</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Vinay&#8217;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">where</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Vikram&#8217;</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span>AutoProc</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>      </span></span><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Calling an ordinary procedure </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">rollback;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">exception</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">then</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:11pt;background:white;color:#008000;font-family:&quot;">&#8211; Procedure without Autonomous Transaction Block (Calee Procedure)<span>   </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">create</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">or</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">replace</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">procedure</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> AutoProc </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">as</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">pragma</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> autonomous_transaction</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">update</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#808000;font-family:&quot;">myemployeemaster</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">set</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Pawan Kumar&#8217;</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">where</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> employeename</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">=</span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">&#8216;vinny&#8217;</span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">commit;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">exception</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">then</span><span style="font-size:11pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;">Explanation- </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Now consider the about block of code. In this code AutoProc Procedure difines the Pragma Autonomous_Transaction. So that it has a different transaction for this procedure . When a Commit operation is performed then it will only commit those transactions which are rekated to this procedure. And when the control goes back to the MainProc then it will rollback the transactions of the MainProc Procedure. So As a result name vinny in the MyEmployeeMaster is changed with the name Pawan Kumar. But<span>  </span>Vikram has not changed with the Vinay.</span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vinayhatwal.wordpress.com/94/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vinayhatwal.wordpress.com/94/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vinayhatwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vinayhatwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vinayhatwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vinayhatwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vinayhatwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vinayhatwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vinayhatwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vinayhatwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vinayhatwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vinayhatwal.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=94&subd=vinayhatwal&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vinayhatwal.wordpress.com/2008/08/25/plsql-pragma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30134ff30180ffc15825d15c005dbce5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vinayhatwal</media:title>
		</media:content>
	</item>
	</channel>
</rss>