<?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; Oracle 10g</title>
	<atom:link href="http://vinayhatwal.wordpress.com/category/oracle-10g/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; Oracle 10g</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>
		<item>
		<title>Oracle Cursors</title>
		<link>http://vinayhatwal.wordpress.com/2008/08/19/oracle-cursors/</link>
		<comments>http://vinayhatwal.wordpress.com/2008/08/19/oracle-cursors/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 04:42:07 +0000</pubDate>
		<dc:creator>vinayhatwal</dc:creator>
				<category><![CDATA[Oracle Cursors]]></category>
		<category><![CDATA[Cursors]]></category>
		<category><![CDATA[Explicit Cursors]]></category>
		<category><![CDATA[Implicit Cursors]]></category>
		<category><![CDATA[Vinayhatwal]]></category>

		<guid isPermaLink="false">http://vinayhatwal.wordpress.com/?p=77</guid>
		<description><![CDATA[ORACLE CURSORS
 
 
Cursors are the work place user by the Oracle engine for its internal processing to save the data returned by the SQL statements. The type of a cursor depends upon the nature of its working. For Example if Oracle Engine open a cursor for its internal processing then it is known as Implicit Cursor [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=77&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:17pt;color:#ff0000;font-family:&quot;">ORACLE CURSORS</span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:11pt;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:13pt;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;color:#000000;font-family:&quot;">Cursors are the work place user by the Oracle engine for its internal processing to save the data returned by the SQL statements. The type of a cursor depends upon the nature of its working. For Example if Oracle Engine open a cursor for its internal processing then it is known as <strong>Implicit Cursor</strong> and is a cursor defined by the user as a user defined cursor then it is called as <strong>Explicit Cursor</strong>.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;">
<p class="MsoNormal" style="margin:0;"> </p>
<p><span style="color:#000000;font-family:&quot;"><span style="font-size:small;"> <a href="http://vinayhatwal.files.wordpress.com/2008/08/cursors3.jpg"><img class="aligncenter size-full wp-image-85" src="http://vinayhatwal.files.wordpress.com/2008/08/cursors3.jpg?w=637&#038;h=232" alt="" width="637" height="232" /></a><a href="http://vinayhatwal.files.wordpress.com/2008/08/cursors2.jpg"></a></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;">
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:17pt;color:#ff0000;font-family:&quot;">Implicit Cursors</span></strong></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:11pt;color:#ff0000;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Implicit Cursors are automatically used by the Oracle Engine to store some information regarding the internal processing of the server. Implicit Cursors are automatically created, fetches records and closed by the oracle database server.</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;">Basically Internal Cursors are used to table the information about last insert, update, delete or single row select statement.</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;font-family:&quot;">Implicit Cursor Attributes</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-indent:-24pt;text-align:justify;margin:0 0 0 42pt;"><strong><span style="font-size:11pt;font-family:&quot;"><span>1)<span style="font-family:&quot;">       </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%ISOPEN </span></strong><span style="font-size:11pt;font-family:&quot;">–<strong> </strong>If the cursor is open then this attribute returns TRUE otherwise returns FALSE. In the case of implicit cursors this attribute always return FALSE because Implicit Cursors are automatically open and the closed by the Oracle Engine.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-indent:-24pt;text-align:justify;margin:0 0 0 42pt;"><strong><span style="font-size:11pt;font-family:&quot;"><span>2)<span style="font-family:&quot;">       </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%FOUND –</span></strong><span style="font-size:11pt;font-family:&quot;"> If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.</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-indent:-24pt;text-align:justify;margin:0 0 0 42pt;"><strong><span style="font-size:11pt;font-family:&quot;"><span>3)<span style="font-family:&quot;">       </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%NOTFOUND –</span></strong><span style="font-size:11pt;font-family:&quot;"> This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.</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-indent:-24pt;text-align:justify;margin:0 0 0 42pt;"><strong><span style="font-size:11pt;font-family:&quot;"><span>4)<span style="font-family:&quot;">       </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%ROWCOUNT – </span></strong><span style="font-size:11pt;font-family:&quot;">You can count number of affected rows by the last SQL statement by using this attribute.<strong></strong></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;">Consider the following block of code-</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Take the table used in the tutorial Native Dynamic SQL (MyEmployeeMaster).</span></span></p>
<div style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:windowtext 1pt solid;padding:0 0 1pt;">
<p class="MsoNormal" style="text-align:justify;margin:0;padding:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
</div>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">OR</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">REPLACE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">PROCEDURE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> demo_imp </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IS</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span> </span>row_deleted </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">30</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">BEGIN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>   </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">update</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#808000;font-family:Courier;">MYEMPLOYEEMASTER</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">set</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> EMPLOYEENAME</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">=</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;Ashish&#8217;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">where</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">upper(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">EMPLOYEENAME</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">)</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">like</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;%V%&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">SQL</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">%ISOPEN </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">THEN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%FOUND &#8211; True&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">else</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%FOUND &#8211; False&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">SQL</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">FOUND</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">THEN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%FOUND &#8211; True&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">else</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%FOUND &#8211; False&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>               </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>             </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">SQL</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">NOTFOUND</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">THEN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%NOTFOUND &#8211; True&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">else</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>            </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%NOTFOUND &#8211; False&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IF;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>   </span><span>      </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;SQL%ROWCOUNT &#8211; &#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> || </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">SQL</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">ROWCOUNT</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216; NO OF ROWS AFFACTED&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> demo_imp</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<div style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:windowtext 1pt solid;padding:0 0 1pt;">
<p class="MsoNormal" style="text-align:justify;margin:0;padding:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
</div>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="text-decoration:underline;"><span style="font-family:&quot;"><span style="font-size:small;">Resule of above procedure – </span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="text-decoration:underline;"><span style="font-family:&quot;"><span style="text-decoration:none;"><span style="font-size:small;"> </span></span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL&gt; set serverout on;</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL&gt;<span>  </span>exec demo_imp;</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL%FOUND &#8211; False</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL%FOUND &#8211; True</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL%NOTFOUND &#8211; False</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">SQL%ROWCOUNT &#8211; 3 NO OF ROWS AFFACTED</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:17pt;color:#ff0000;font-family:&quot;">Explicit Cursors –</span></strong></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:17pt;color:#ff0000;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Explicit Cursors are explicitly used by the user for the data processing. Explicit Cursors are not automatically opens and close by like an Implicit Cursor. It is declare, open and close by the user in the PL/SQL block. Following are the steps to take by the user for using the Explicit Cursors in their PL/SQL block.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;text-align:justify;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">1)</span><span style="font-family:&quot;">              </span></span></span><span style="font-family:&quot;"><span style="font-size:small;">Declare the cursor in the declaration section with CURSOR keyword.</span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;text-align:justify;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">2)</span><span style="font-family:&quot;">              </span></span></span><span style="font-family:&quot;"><span style="font-size:small;">Open the declared Cursor by using the OPEN keyword.</span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;text-align:justify;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">3)</span><span style="font-family:&quot;">              </span></span></span><span style="font-family:&quot;"><span style="font-size:small;">Fetch the Record from the opened cursor by the FETCH … INTO keywords.</span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;text-align:justify;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">4)</span><span style="font-family:&quot;">              </span></span></span><span style="font-family:&quot;"><span style="font-size:small;">Process the data in the cursor by using the loop by using the LOOP…. END LOOP block.</span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;text-align:justify;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">5)</span><span style="font-family:&quot;">              </span></span></span><span style="font-family:&quot;"><span style="font-size:small;">Fetch the next record and point out the pointer to the next record by using the FETCH…. INTO.</span></span></p>
<p class="MsoNormal" style="text-indent:-0.5in;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span><span style="font-size:small;">6)</span><span style="font-family:&quot;">              </span></span></span></p>
<div class="MsoNormal" style="text-indent:-0.5in;margin:0 0 0 0.75in;"><span style="font-family:&quot;"><span style="font-size:small;">Close the opened cursor by using the CLOSE keyword.</span></span></div>
<div><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></div>
<div><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></div>
<p><span style="font-family:&quot;"><span style="font-size:small;"> </p>
<p></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;font-family:&quot;">Explicit Cursor Attributes-</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;font-family:&quot;"><span>                </span></span></strong></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><strong><span style="font-size:11pt;font-family:&quot;"><span>1)<span style="font-family:&quot;">   </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%ISOPEN </span></strong><span style="font-size:11pt;font-family:&quot;">–<strong> </strong>If the cursor is open then this attribute returns TRUE otherwise returns FALSE.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><strong><span style="font-size:11pt;font-family:&quot;"><span>2)<span style="font-family:&quot;">   </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%FOUND –</span></strong><span style="font-size:11pt;font-family:&quot;"> If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><strong><span style="font-size:11pt;font-family:&quot;"><span>3)<span style="font-family:&quot;">   </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%NOTFOUND –</span></strong><span style="font-size:11pt;font-family:&quot;"> This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><strong><span style="font-size:11pt;font-family:&quot;"><span>4)<span style="font-family:&quot;">   </span></span></span></strong><strong><span style="font-size:11pt;font-family:&quot;">SQL%ROWCOUNT – </span></strong><span style="font-size:11pt;font-family:&quot;">You can count number of affected rows by the last SQL statement by using this attribute.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<div style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:windowtext 1pt solid;padding:0 0 1pt;">
<p class="MsoNormal" style="text-align:justify;margin:0;padding:0;"><span style="font-family:&quot;"><span style="font-size:small;">Consider the following block of code</span></span></p>
</div>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">OR</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">REPLACE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">PROCEDURE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> demo_exp </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IS</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span> </span>cur sys_refcursor</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>   </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span> </span>employeeidx </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span> </span>eployeenamex </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">20</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">BEGIN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>   </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">open</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> cur </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">for</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">select</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> employeeid</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> employeename </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">from</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#808000;font-family:Courier;">myemployeemaster</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">fetch</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> cur </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> employeeidx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">eployeenamex </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">while</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> cur%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">found</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">loop</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;employeeid: &#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> || employeeidx<span>  </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;&#8212;-&#8217;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;eployeename: &#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> || eployeenamex </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">fetch</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> cur </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> employeeidx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">eployeenamex </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">commit;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">end</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">loop;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> demo_imp</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span><span style="font-size:small;"><span style="font-family:&quot;"><span>       </span></span><strong></strong></span></p>
<div style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:windowtext 1pt solid;padding:0 0 1pt;">
<p class="MsoNormal" style="text-align:justify;margin:0;padding:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
</div>
<p>&lt;p class=&#8221;MsoNormal&#8221; style=&#8221;text-align:justify;margin:0;&#8221;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vinayhatwal.wordpress.com/77/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vinayhatwal.wordpress.com/77/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vinayhatwal.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vinayhatwal.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vinayhatwal.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vinayhatwal.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vinayhatwal.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vinayhatwal.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vinayhatwal.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vinayhatwal.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vinayhatwal.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vinayhatwal.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=77&subd=vinayhatwal&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vinayhatwal.wordpress.com/2008/08/19/oracle-cursors/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>

		<media:content url="http://vinayhatwal.files.wordpress.com/2008/08/cursors3.jpg" medium="image" />
	</item>
		<item>
		<title>Native Dynamic SQL</title>
		<link>http://vinayhatwal.wordpress.com/2008/08/18/native-dynamic-sql/</link>
		<comments>http://vinayhatwal.wordpress.com/2008/08/18/native-dynamic-sql/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:53:49 +0000</pubDate>
		<dc:creator>vinayhatwal</dc:creator>
				<category><![CDATA[Native Dynamic SQL]]></category>
		<category><![CDATA[Dynamic SQL]]></category>
		<category><![CDATA[Oracle 10g]]></category>
		<category><![CDATA[Vinayhatwal]]></category>

		<guid isPermaLink="false">http://vinayhatwal.wordpress.com/?p=74</guid>
		<description><![CDATA[Native Dynamic SQL
 
Hello friends,
I am again come with new tutorial, Native Dynamic SQL. In this tutorial we will learn – 
 
1)   What is Native Dynamic SQL
2)   How it can be used in PL/SQL
3)   Benefits of the Native Dynamic SQL.
 
What is Native Dynamic SQL?
 
Native dynamic SQL is the mechanism where you can dynamically perform the operation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=74&subd=vinayhatwal&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="text-align:center;margin:0;"><strong><span style="font-size:22pt;color:#ff0000;font-family:&quot;">Native Dynamic SQL</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:22pt;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Hello friends,</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">I am again come with new tutorial, Native Dynamic SQL. In this tutorial we will learn – </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-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><span style="font-size:11pt;font-family:&quot;"><span>1)<span style="font-family:&quot;">   </span></span></span><span style="font-size:11pt;font-family:&quot;">What is Native Dynamic SQL</span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><span style="font-size:11pt;font-family:&quot;"><span>2)<span style="font-family:&quot;">   </span></span></span><span style="font-size:11pt;font-family:&quot;">How it can be used in PL/SQL</span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><span style="font-size:11pt;font-family:&quot;"><span>3)<span style="font-family:&quot;">   </span></span></span><span style="font-size:11pt;font-family:&quot;">Benefits of the Native Dynamic SQL.</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;font-family:&quot;">What is Native Dynamic SQL?</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="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Native dynamic SQL is the mechanism where you can dynamically perform the operation on the oracle database schemas. Native dynamic SQL makes your program more flexible in such situations where you don’t know any information about what to do, in advance. Consider the situation where a reporting tool maintain data on daily basis and there are a lot of source table which contain the data on the basis of some parameters and these parameters can also be changed at run time. So what you will do in this situation. Native Dynamic SQL can be used to handle this type of situation.</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;">Native Dynamic SQL statement can be built same as a string variable. And also the bind variables can be used with them to improve the performance of the operations. Remember when you perform any of the operation with PL/SQL, PL/SQL automatically convert the variables of the statement to the bind variable to improve the performance of the statement. When you build up such statements with the Native Dynamic SQL then you have to specify the bind variables with the statement, however it is not mandatory. If you will not give the bind variable, PL/SQL will automatically convert them into bind variables but it will give more overhead on the Server.<span>   </span></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;">So, The Native Dynamic SQL statements can be generated at the run time (dynamically).</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;font-family:&quot;">How it can be used in PL/SQL</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="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Native Dynamic SQL statements can be executed by using EXECUTE IMMEDIATE statement following by the single quoted varchar variable with SQL statement.</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="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">DECLARE</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span>str </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">VARCHAR2</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">4000</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">BEGIN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span>str</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;DELETE FROM STUDENT_MASTER WHERE STUDENT_ID=1&#8242;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">EXECUTE</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">IMMEDIATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> str</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">EXCEPTION</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">WHEN</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">OTHERS</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">THEN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>      </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">NULL;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;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></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">Above example just delete the student with student id =1.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">You can also use bind variable with the Native Dynamic SQL for improving the performance of the direct SQL statements.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:15pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:22pt;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:11pt;font-family:&quot;">Benefits of the Native Dynamic SQL</span></strong></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><span style="font-size:11pt;font-family:&quot;"><span>1)<span style="font-family:&quot;">   </span></span></span><span style="font-size:11pt;font-family:&quot;">You can use DDL (CREATE TABLE, DROP TABLE, ALTER TABLE etc) statements and DCL Statements with the PL/SQL block. In PL/SQL these statement can’t be executed statically.</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="text-indent:-0.25in;text-align:justify;margin:0 0 0 0.5in;"><span style="font-size:11pt;font-family:&quot;"><span>2)<span style="font-family:&quot;">   </span></span></span><span style="font-size:11pt;font-family:&quot;">By using Native Dynamic SQL statements you can create the SQL statements with using different WHERE clause conditions in a SELECT statement.</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 0 0 0.25in;"><span style="font-size:11pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;">EXECUTE IMMEDIATE </span></strong><span style="font-size:10pt;color:#ff0000;font-family:&quot;">The Magic statement to execute Dynamic SQL</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#ff0000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">EXECUTE IMMEDIATE is the statement for executing the SQL statements dynamically in the PL/SQL block or even for executing the PL/SQL block itself.</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;font-family:&quot;">Syntax of Execute immediate -</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:9pt;font-family:&quot;">EXECUTE IMMEDIATE dynamic_string</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;font-family:&quot;">[INTO {define_variable[, define_variable]&#8230; | record}]</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;font-family:&quot;">[USING [IN | OUT | IN OUT] bind_argument</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;font-family:&quot;">[, [IN | OUT | IN OUT] bind_argument]&#8230;]</span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:9pt;font-family:&quot;">[{RETURNING | RETURN} INTO bind_argument[, bind_argument]&#8230;];</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;font-family:&quot;">Brief Explanation – </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="text-align:justify;margin:0;"><span style="font-size:11pt;font-family:&quot;">EXECUTE IMMEDIATE is used to dynamically execute the SQL statement where dynamic_string is the string type variable which contains the Dynamic SQL. INTO clause is used to take the selected values form the query into the defined variables and record is the %ROWTYPE or user defined records. USING clause is used to take IN or OUT bind variables. RETURNING INTO clause is used with the DML statements which have the RETURNING clause with them for returning the affected column value. </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;">Consider the following example &#8211; </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="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">OR</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">REPLACE</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">procedure</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> WEALTHMAKER</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">.</span><span style="font-size:10pt;background:white;color:#808000;font-family:&quot;">MyTest</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">as</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">sql1 </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">varchar</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">4000</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">myrefcur sys_refcursor</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeecodex </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeenamex </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">20</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salarymonthx </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">20</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryyearx </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">20</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryx </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">20</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryy </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">TYPE</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> RefEmpTyp </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">IS</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">REF</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">CURSOR;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> RefEmpTyp</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">/***************************************************************************************</span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>                                                </span>BLOCK1<span>   </span>-<span>    </span>DCL STATEMENT </span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span>***************************************************************************************/</span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Droping table if exists </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;drop table MyEmployeeMaster&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Droping table if exists </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;drop table MyEmployeeSalary&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span><span> </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Droping view if exists </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>     </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;drop view MyClientView&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Creating a master table </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;create table MyEmployeeMaster(EmployeeId number,EmployeeName varchar2(20))&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Creating Detailed Table </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;create table MyEmployeeSalary(EmployeeId number,Salary varchar2(20),SalaryMonth number,SalaryYear number)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">null;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">/******************************************************************************************</span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>                                                </span>BLOCK2<span>  </span>-<span>    </span>DML STATEMENT </span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span>******************************************************************************************/</span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Inserting values in Master Table </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeMaster values (1,&#8221;Vinay Hatwal&#8221;)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeMaster values (2,&#8221;Piyush Aggrawal&#8221;)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeMaster values (3,&#8221;Vinita Sharma&#8221;)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeMaster values (4,&#8221;Varsha Dhiman&#8221;)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeMaster values (5,&#8221;Pawan Kumar&#8221;)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Inserting Values in Detailed Table </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (1,2000,2,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (1,2000,3,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (1,2000,4,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (1,2000,5,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (2,2000,2,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (2,2000,3,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (2,2000,4,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (2,2000,5,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (3,2000,2,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;insert into MyEmployeeSalary values (3,2000,4,2008)&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>   </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">commit;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">/******************************************************************************************</span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>                </span><span>                                </span>BLOCK3<span>   </span>-<span>    </span>QUERY<span>  </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span>******************************************************************************************/</span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">&#8211; Creating View for Displaying </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span>SQL1</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216; create or replace view MyClientView as<span>  </span>&#8216;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span>SQL1</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> SQL1 || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8217;select m.EmployeeId,m.EmployeeName,s.SALARYMONTH,s.SALARYYEAR,s.SALARY from MyEmployeeSalary s, MyEmployeeMaster m<span>  </span>&#8216;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span>SQL1</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> SQL1 || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;where s.EmployeeId(+)=m.EmployeeId and (s.salarymonth=&#8221;02&#8221; or s.salarymonth is null)<span>  </span>&#8216;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> sql1</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">open</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">for</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8217;select * from MyClientView&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">loop</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">fetch</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> employeecodex</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeenamex</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salarymonthx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryyearx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">EXIT</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">WHEN</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">NOTFOUND;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span><strong><em>dbms_output.PUT_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeecodex || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || employeenamex<span>  </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salarymonthx<span>   </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salaryyearx<span>   </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salaryx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">loop;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;">/******************************************************************************************</span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>                                     </span>BLOCK4<span>  </span>-<span>    </span>DML STATEMENT WITH RETURNING INTO VLAUSE </span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><em><span style="font-size:10pt;background:white;color:#008000;font-family:&quot;"><span>    </span>******************************************************************************************/</span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;update MyEmployeeSalary set salary=50000 where employeeid=1 and salarymonth=2 and salaryyear=2008 returning salary into :2&#8242;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">returning</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> salaryy</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">commit;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span><strong><em>dbms_output.PUT_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8221;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span><strong><em>dbms_output.PUT_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8221;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span><strong><em>dbms_output.PUT_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;Updated Salary&#8212;-&#8217;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salaryy</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">open</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">for</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8217;select * from MyClientView&#8217;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">loop</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">fetch</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> employeecodex</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeenamex</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salarymonthx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryyearx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">salaryx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">EXIT</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">WHEN</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">cv</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">%</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">NOTFOUND;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>        </span><strong><em>dbms_output.PUT_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;">employeecodex || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || employeenamex<span>  </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salarymonthx<span>   </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salaryyearx<span>   </span>|| </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">&#8216;<span>     </span>&#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> || salaryx</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">loop;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:&quot;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:&quot;"><span>    </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">(SQLERRM(SQLCODE));</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:&quot;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="text-decoration:underline;"><span style="font-size:11pt;font-family:&quot;">Brief Explanation – </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:small;"><strong><span style="font-family:&quot;">BLOCK 1</span></strong><span style="font-family:&quot;"> – Specifies the DDL statement, some Tables are dropped and Some Tables are created with using the dynamic SQL.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:small;"><strong><span style="font-family:&quot;">BLOCK 2</span></strong><span style="font-family:&quot;"> – Specifies some DML statements which insert values into the table created in the BLOCK 1.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:small;"><strong><span style="font-family:&quot;">BLOCK 3</span></strong><span style="font-family:&quot;"> – View is created to show the data at the run time by using the Implicit Cursor for the Query.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:small;"><strong><span style="font-family:&quot;">BLOCK 4</span></strong><span style="font-family:&quot;"> – Specifies DML statement UPDATE to show the working of RETURNING INTO clause with the EXECUTE IMMEDIATE.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"><span> </span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;">USING Vs. RETURNING INTO </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">By using OUT parameter with USING clause you can also take the advantage of the RETURNING INTO clause.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Consider the following block of code –</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#ff0000;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">OR</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">REPLACE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">procedure</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> WEALTHMAKER</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">.</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">UsingVsRETINTO </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">as</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">str </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">varchar2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">4000</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bsalary </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bsalary_out </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bemployeeid </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bmonth </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">byear </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">number</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">begin</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>bsalary</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">40000</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>bemployeeid</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">1</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>bmonth</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>byear</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">2008</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>str</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216; update myemployeesalary set salary=:bind_salary where employeeid=:bind_employeeid<span>  </span>&#8216;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>str</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> str || </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;<span>    </span>and salarymonth=:bind_month and salaryyear=:bind_year returning salary into :bindsalaryret &#8216;</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:Courier;">&#8211;Statement 1 </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> str </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">using</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> bsalary</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bemployeeid</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bmonth</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">byear</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,out</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> bsalary_out</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bsalary_out</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span>bsalary</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">:=</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">50000</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><em><span style="font-size:10pt;background:white;color:#008000;font-family:Courier;">&#8211;Statement 1 </span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">execute</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">immediate</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> str </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">using</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> bsalary</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bemployeeid</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bmonth</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">,</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">byear </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">returning</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">into</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>  </span>bsalary_out</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">bsalary_out</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">);</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">exception</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">when</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">others</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">then</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"><span>    </span><strong><em>dbms_output.put_line</em></strong></span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(SQLERRM(SQLCODE));</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">end;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">In the above example you can see in Statement 1, the updated salary is taken out into bsalary_out OUT parameter by using the USING clause</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">But in the case of Statement 2, updated salary is taken out by using the RETURNING INTO clause.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">So, finally you can use any of the statement to return the result of the DML statement.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><em><span style="font-family:&quot;"><span style="font-size:small;">The only difference in these two statements is, with USING clause all the followed parameter are IN mode by default, it means you need not to specify the IN mode for the variable, On the other hand in the case of RETURNING INTO clause all the variables are in the OUT mode by default. </span></span></em></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;">Using Schema Name with Dynamic SQL</span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Suppose you want to user the Scheme name with the Dynamic SQL then normally you might write the code like the following – </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">PROCEDURE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> drop_some_table </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">tablename </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">)</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">AS</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">BEGIN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">EXECUTE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IMMEDIATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;DROP TABLE :tab&#8217;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">USING</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> table_name</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Courier;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">But Remember, you will find the error <em>Invalid Table Name </em>because you can’t use bind variables with any schema name. So you should write the following code to debug the above code.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">CREATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">PROCEDURE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> drop_some_table </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">(</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;">tablename </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">)</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">AS</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">BEGIN</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">EXECUTE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">IMMEDIATE</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#ff0000;font-family:Courier;">&#8216;DROP TABLE &#8216;</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> </span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">||</span><span style="font-size:10pt;background:white;color:#000000;font-family:Courier;"> table_name</span><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;background:white;color:#0000ff;font-family:Courier;">END;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;"> </span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:16pt;color:#ff0000;font-family:&quot;">Duplicate Placeholders</span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Placeholders in Dynamic SQL are the elements by which the bind variables are associated with the corresponding item followed by the USING clause. These variables are associated with the values by the position not by the name. So remember the you can use the same name with the placeholders. For examples consider the following line of code:</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">sql_stmt := ’INSERT INTO payroll VALUES (:x, <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> , :y, <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> )’;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">it does not matter you are writing the execute stament like this</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">EXECUTE IMMEDIATE sql_stmt USING a, a, b, a;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Or </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">EXECUTE IMMEDIATE sql_stmt USING a, b, b, a;</span></span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vinayhatwal.wordpress.com/74/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vinayhatwal.wordpress.com/74/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vinayhatwal.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vinayhatwal.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vinayhatwal.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vinayhatwal.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vinayhatwal.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vinayhatwal.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vinayhatwal.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vinayhatwal.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vinayhatwal.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vinayhatwal.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=74&subd=vinayhatwal&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vinayhatwal.wordpress.com/2008/08/18/native-dynamic-sql/feed/</wfw:commentRss>
		<slash:comments>1</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>