<?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 Cursors</title>
	<atom:link href="http://vinayhatwal.wordpress.com/category/oracle-10g/oracle-cursors/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 Cursors</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>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>
	</channel>
</rss>