<?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>Edi Yanto (何 萬 新) &#187; query</title>
	<atom:link href="http://ediyanto83.wordpress.com/tag/query/feed/" rel="self" type="application/rss+xml" />
	<link>http://ediyanto83.wordpress.com</link>
	<description>Welcome to my weblog</description>
	<lastBuildDate>Sun, 08 Nov 2009 07:24:26 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ediyanto83.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a744dbd9a2c0cfeb9b03e383ec662828?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Edi Yanto (何 萬 新) &#187; query</title>
		<link>http://ediyanto83.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ediyanto83.wordpress.com/osd.xml" title="Edi Yanto (何 萬 新)" />
		<item>
		<title>Row Numbering With an Order By Clause</title>
		<link>http://ediyanto83.wordpress.com/2009/03/07/row-numbering-with-an-order-by-clause/</link>
		<comments>http://ediyanto83.wordpress.com/2009/03/07/row-numbering-with-an-order-by-clause/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 04:27:37 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Programming Concepts]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/?p=466</guid>
		<description><![CDATA[ 
One of the most often uses of the pseudo column rownum is to provide sequence numbers to the records in a query. This feature is widely used in reports to represent systematic display of information.
SELECT   ROWNUM, rcta.trx_number, rcta.trx_date
FROM ra_customer_trx_all rcta;

ROWNUM    TRX_NUMBER    TRX_DATE
1    40881-05    12/14/2005
2    38384-05    11/24/2005
3    42740-05    12/28/2005
4    42742-05    12/28/2005
5    08883-07    3/12/2007
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..
However, when we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=466&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0cm; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 90.0pt 72.0pt 90.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p>One of the most often uses of the pseudo column <strong>rownum </strong>is to provide sequence numbers to the records in a query. This feature is widely used in reports to represent systematic display of information.</p>
<p><strong>SELECT   ROWNUM, rcta.trx_number, rcta.trx_date<br />
FROM ra_customer_trx_all rcta;</strong></p>
<p class="MsoNormal">
<p>ROWNUM    TRX_NUMBER    TRX_DATE<br />
1    40881-05    12/14/2005<br />
2    38384-05    11/24/2005<br />
3    42740-05    12/28/2005<br />
4    42742-05    12/28/2005<br />
5    08883-07    3/12/2007<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<br />
However, when we order this statement the rownum gets disturbed as shown below:</p>
<p><strong>SELECT   ROWNUM, rcta.trx_number, rcta.trx_date<br />
FROM ra_customer_trx_all rcta<br />
ORDER BY rcta.trx_number;</strong></p>
<p>ROWNUM    TRX_NUMBER    TRX_DATE<br />
6427    00001-09    1/2/2009<br />
10827    00001-09CM    1/6/2009<br />
6361    00002-09    1/2/2009<br />
10828    00002-09CM    1/6/2009<br />
6248    00003-09    1/2/2009<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p>
<p>As we can see from above the transaction number did get ordered but the rownum also got the wrong order.<span> </span>To achieve this we have to outer join this table with dual that process forces a implicit order on the rownum as shown below.</p>
<p><strong>SELECT   ROWNUM, rcta.trx_number, rcta.trx_date<br />
FROM ra_customer_trx_all rcta, DUAL d<br />
WHERE rcta.trx_number = d.dummy(+)<br />
ORDER BY rcta.trx_number;</strong></p>
<p>ROWNUM    TRX_NUMBER    TRX_DATE<br />
1    00001-09    1/2/2009<br />
2    00001-09CM    1/6/2009<br />
3    00002-09    1/2/2009<br />
4    00002-09CM    1/6/2009<br />
5    00003-09    1/2/2009<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p>
<p>The trick is to do an outer join with the column that you want to order and this process does not disturb the rownum order.<span> </span>In addition to that if the column is of number datatype <span> </span>then one should make sure to use TO_CHAR datatype conversion function</p>
Posted in Oracle, Programming Concepts Tagged: query <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/466/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=466&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2009/03/07/row-numbering-with-an-order-by-clause/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>
	</item>
		<item>
		<title>Recompile Invalid Objects using DBMS_DDL or Custom Script Using EXECUTE IMMEDIATE</title>
		<link>http://ediyanto83.wordpress.com/2009/01/07/recompile-invalid-objects-using-dbms_ddl-or-custom-script-using-execute-immediate/</link>
		<comments>http://ediyanto83.wordpress.com/2009/01/07/recompile-invalid-objects-using-dbms_ddl-or-custom-script-using-execute-immediate/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 04:49:53 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/?p=345</guid>
		<description><![CDATA[Operations such as upgrades, patches and DDL changes can invalidate schema objects.  For this reason it makes sense to recompile invalid objects in advance of user calls. It also allows you to identify if any changes have broken your code base.
In order to compile a program, you must own that program (in other words, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=345&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Operations such as upgrades, patches and DDL changes can invalidate schema objects.  For this reason it makes sense to recompile invalid objects in advance of user calls. It also allows you to identify if any changes have broken your code base.</p>
<p>In order to compile a program, you must own that program (in other words, the schema you specify is the owner of the program for which you request compilation) or your schema must have been granted the ALTER ANY PROCEDURE privilege to compile another schema&#8217;s programs.</p>
<pre class="programlisting">GRANT ALTER ANY PROCEDURE TO name_of_user;</pre>
<p><strong>DBMS_DDL.ALTER_COMPILE<br />
</strong></p>
<blockquote><p>CREATE OR REPLACE PROCEDURE recompile_objects<br />
(status_in IN VARCHAR2 := &#8216;INVALID&#8217;,<br />
name_in IN VARCHAR2 := &#8216;%&#8217;,<br />
type_in IN VARCHAR2 := &#8216;%&#8217;,<br />
schema_in IN VARCHAR2 := USER)<br />
IS<br />
v_objtype VARCHAR2(100);</p>
<p>CURSOR obj_cur IS<br />
SELECT owner, object_name, object_type<br />
FROM ALL_OBJECTS<br />
WHERE status LIKE UPPER (status_in)<br />
AND object_name LIKE UPPER (name_in)<br />
AND object_type LIKE UPPER (type_in)<br />
AND owner LIKE UPPER (schema_in)<br />
ORDER BY<br />
DECODE (object_type,<br />
&#8216;PACKAGE&#8217;, 1,<br />
&#8216;FUNCTION&#8217;, 2,<br />
&#8216;PROCEDURE&#8217;, 3,<br />
&#8216;PACKAGE BODY&#8217;, 4);<br />
BEGIN<br />
FOR rec IN obj_cur<br />
LOOP<br />
IF rec.object_type = &#8216;PACKAGE&#8217;<br />
THEN<br />
v_objtype := &#8216;PACKAGE SPECIFICATION&#8217;;<br />
ELSE<br />
v_objtype := rec.object_type;<br />
END IF;</p>
<p>DBMS_DDL.ALTER_COMPILE (v_objtype, rec.owner, rec.object_name);</p>
<p>DBMS_OUTPUT.PUT_LINE<br />
(&#8216;Compiled &#8216; || v_objtype || &#8216; of &#8216; ||<br />
rec.owner || &#8216;.&#8217; || rec.object_name);<br />
END LOOP;<br />
END recompile_objects;<br />
/</p></blockquote>
<p class="para">The ALTER_COMPILE procedure may raise any of the following exceptions:</p>
<dl class="variablelist">
<dt class="term">ORA-20000</dt>
<dd class="listitem">
<p class="para">Insufficient privileges or object does not exist. You must either own the specified object or be granted the CREATE ANY PROCEDURE privilege.</p>
</dd>
<dt class="term">ORA-20001</dt>
<dd class="listitem">
<p class="para">Remote object, cannot compile. You can only recompile objects on the local database instance.</p>
</dd>
<dt class="term">ORA-20002</dt>
<dd class="listitem">
<p class="para">Bad value for object type. You need to provide one of the values listed in the previous section.</p>
</dd>
</dl>
<p class="para">Notice that these exceptions are not defined in the specification of the package. Instead, ALTER_COMPILE simply calls RAISE_APPLICATION_ERROR with one of the above error numbers. These error numbers may therefore conflict with your own -20NNN error number usages. If you embed calls to ALTER_COMPILE inside your application or utility, watch out for the confusion such conflicts can cause.</p>
<p class="para">
<p><strong>Custom Script Using EXECUTE IMMEDIATE</strong></p>
<blockquote><p>CREATE OR REPLACE PROCEDURE recompile_object<br />
AS<br />
CURSOR my_cur<br />
IS<br />
SELECT   *<br />
FROM dba_objects<br />
WHERE status = &#8216;INVALID&#8217;<br />
ORDER BY owner, object_type, object_name;<br />
BEGIN<br />
FOR cur IN my_cur<br />
LOOP<br />
BEGIN<br />
IF cur.object_type = &#8216;PACKAGE BODY&#8217;<br />
THEN<br />
EXECUTE IMMEDIATE    &#8216;ALTER PACKAGE &#8216;<br />
|| cur.owner<br />
|| &#8216;.&#8217;<br />
|| cur.object_name<br />
|| &#8216; COMPILE BODY&#8217;;<br />
ELSE<br />
EXECUTE IMMEDIATE    &#8216;ALTER &#8216;<br />
|| cur.object_type<br />
|| &#8216; &#8216;<br />
|| cur.owner<br />
|| &#8216;.&#8217;<br />
|| cur.object_name<br />
|| &#8216; COMPILE&#8217;;<br />
END IF;<br />
EXCEPTION<br />
WHEN OTHERS<br />
THEN<br />
DBMS_OUTPUT.put_line (SQLERRM);<br />
DBMS_OUTPUT.put_line (   cur.object_type<br />
|| &#8216; : &#8216;<br />
|| cur.owner<br />
|| &#8216; : &#8216;<br />
|| cur.object_name<br />
);<br />
END;<br />
END LOOP;<br />
EXCEPTION<br />
WHEN OTHERS<br />
THEN<br />
DBMS_OUTPUT.put_line (SQLERRM);<br />
END recompile_object;<br />
/<br />
<strong></strong></p></blockquote>
<p><strong><br />
</strong></p>
Posted in Oracle Tagged: development, performance, query <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=345&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2009/01/07/recompile-invalid-objects-using-dbms_ddl-or-custom-script-using-execute-immediate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>
	</item>
		<item>
		<title>Spell Number</title>
		<link>http://ediyanto83.wordpress.com/2008/10/28/spell-number/</link>
		<comments>http://ediyanto83.wordpress.com/2008/10/28/spell-number/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 06:14:33 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/?p=167</guid>
		<description><![CDATA[CREATE OR REPLACE PACKAGE spell_number_pkg AS
/*
Spell Number in Indonesia and English
*/
AMOUNT_EXCEEDS_LIMIT EXCEPTION;
function to_words(
p_amount number
) return varchar2;
function spell_number(
p_number in number
) return varchar2;
END spell_number_pkg;
CREATE OR REPLACE PACKAGE BODY spell_number_pkg
IS
/*
Spell Number in Indonesia and English
*/
&#8211;*******************************************************************
&#8211;* PRIVATE MEMBERS
TYPE varchar2_tbl_t IS TABLE OF VARCHAR2 (30);
FUNCTION to_hundredth_words (p_amount NUMBER)
RETURN VARCHAR2
IS
l_translate_groups   varchar2_tbl_t
:= varchar2_tbl_t (&#8216;SATU&#8217;,
&#8216;DUA&#8217;,
&#8216;TIGA&#8217;,
&#8216;EMPAT&#8217;,
&#8216;LIMA&#8217;,
&#8216;ENAM&#8217;,
&#8216;TUJUH&#8217;,
&#8216;DELAPAN&#8217;,
&#8216;SEMBILAN&#8217;
);
l_tenth_groups       varchar2_tbl_t
:= varchar2_tbl_t (&#8221;, &#8216;PULUH&#8217;, &#8216;RATUS&#8217;);
l_char               VARCHAR2 (3);
l_length             NUMBER;
l_number             [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=167&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>CREATE OR REPLACE PACKAGE spell_number_pkg AS<br />
/*<br />
Spell Number in Indonesia and English<br />
*/<br />
AMOUNT_EXCEEDS_LIMIT EXCEPTION;</p>
<p>function to_words(<br />
p_amount number<br />
) return varchar2;</p>
<p>function spell_number(<br />
p_number in number<br />
) return varchar2;<br />
END spell_number_pkg;</p>
<p>CREATE OR REPLACE PACKAGE BODY spell_number_pkg<br />
IS<br />
/*<br />
Spell Number in Indonesia and English<br />
*/<br />
&#8211;*******************************************************************<br />
&#8211;* PRIVATE MEMBERS<br />
TYPE varchar2_tbl_t IS TABLE OF VARCHAR2 (30);</p>
<p>FUNCTION to_hundredth_words (p_amount NUMBER)<br />
RETURN VARCHAR2<br />
IS<br />
l_translate_groups   varchar2_tbl_t<br />
:= varchar2_tbl_t (&#8216;SATU&#8217;,<br />
&#8216;DUA&#8217;,<br />
&#8216;TIGA&#8217;,<br />
&#8216;EMPAT&#8217;,<br />
&#8216;LIMA&#8217;,<br />
&#8216;ENAM&#8217;,<br />
&#8216;TUJUH&#8217;,<br />
&#8216;DELAPAN&#8217;,<br />
&#8216;SEMBILAN&#8217;<br />
);<br />
l_tenth_groups       varchar2_tbl_t<br />
:= varchar2_tbl_t (&#8221;, &#8216;PULUH&#8217;, &#8216;RATUS&#8217;);<br />
l_char               VARCHAR2 (3);<br />
l_length             NUMBER;<br />
l_number             NUMBER;<br />
l_words              VARCHAR2 (2000);<br />
BEGIN<br />
l_char := TO_CHAR (p_amount);<br />
l_length := LENGTH (l_char);</p>
<p>FOR i IN 1 .. l_length<br />
LOOP<br />
l_number := TO_NUMBER (SUBSTR (l_char, l_length + 1 &#8211; i, 1));</p>
<p>IF (l_number != 0)<br />
THEN<br />
l_words :=<br />
l_translate_groups (l_number)<br />
|| RTRIM (&#8216; &#8216; || l_tenth_groups (i))<br />
|| RTRIM (&#8216; &#8216; || l_words);<br />
END IF;<br />
END LOOP;</p>
<p>IF (l_words IS NOT NULL)<br />
THEN<br />
l_words := REPLACE (l_words, &#8216;SATU RATUS&#8217;, &#8216;SERATUS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SATU PULUH SATU&#8217;, &#8216;SEBELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SATU PULUH&#8217;, &#8216;SEPULUH&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH DUA&#8217;, &#8216;DUA BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH TIGA&#8217;, &#8216;TIGA BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH EMPAT&#8217;, &#8216;EMPAT BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH LIMA&#8217;, &#8216;LIMA BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH ENAM&#8217;, &#8216;ENAM BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH TUJUH&#8217;, &#8216;TUJUH BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH DELAPAN&#8217;, &#8216;DELAPAN BELAS&#8217;);<br />
l_words := REPLACE (l_words, &#8216;SEPULUH SEMBILAN&#8217;, &#8216;SEMBILAN BELAS&#8217;);<br />
END IF;</p>
<p>RETURN l_words;<br />
END to_hundredth_words;</p>
<p>&#8211;**********************************************************<span id="more-167"></span><br />
&#8211;* PUBLIC MEMBERS<br />
FUNCTION to_words (p_amount NUMBER)<br />
RETURN VARCHAR2<br />
IS<br />
l_thousandth_groups   varchar2_tbl_t<br />
:= varchar2_tbl_t (&#8221;, &#8216;RIBU&#8217;, &#8216;JUTA&#8217;, &#8216;MILIAR&#8217;, &#8216;TRILIUN&#8217;);<br />
l_idx                 NUMBER          := 1;<br />
l_amount              NUMBER;<br />
l_fraction            NUMBER;<br />
l_hundredth_words     VARCHAR2 (240);<br />
l_words               VARCHAR2 (2000);<br />
BEGIN<br />
l_amount := TRUNC (ABS (p_amount));</p>
<p>IF (LENGTH (TO_CHAR (l_amount)) &gt; 3 * l_thousandth_groups.COUNT)<br />
THEN<br />
RAISE amount_exceeds_limit;<br />
END IF;</p>
<p>l_fraction := ABS (ROUND (p_amount, 2)) &#8211; l_amount;</p>
<p>LOOP<br />
l_hundredth_words :=<br />
to_hundredth_words (l_amount &#8211; TRUNC (l_amount, -3));</p>
<p>IF (l_hundredth_words IS NOT NULL)<br />
THEN<br />
l_words :=<br />
l_hundredth_words<br />
|| RTRIM (&#8216; &#8216; || l_thousandth_groups (l_idx))<br />
|| RTRIM (&#8216; &#8216; || l_words);<br />
END IF;</p>
<p>l_amount := TRUNC (l_amount, -3) / 1000;<br />
EXIT WHEN l_amount = 0;<br />
l_idx := l_idx + 1;<br />
END LOOP;</p>
<p>IF (SUBSTR (l_words, 1, 9) = &#8216;SATU RIBU&#8217;)<br />
THEN<br />
l_words := &#8216;SERIBU&#8217; || SUBSTR (l_words, 10);<br />
END IF;</p>
<p>l_words := l_words;</p>
<p>IF (l_fraction != 0)<br />
THEN<br />
l_words :=<br />
l_words || &#8216; &#8216; || to_hundredth_words (l_fraction * 100)<br />
|| &#8216; SEN&#8217;;<br />
END IF;</p>
<p>RETURN l_words;<br />
END to_words;</p>
<p>CREATE OR REPLACE FUNCTION spell_number (p_number IN NUMBER)<br />
RETURN VARCHAR2<br />
AS<br />
TYPE myarray IS TABLE OF VARCHAR2 (255);</p>
<p>l_str      myarray<br />
:= myarray (&#8221;,<br />
&#8216; thousand &#8216;,<br />
&#8216; million &#8216;,<br />
&#8216; billion &#8216;,<br />
&#8216; trillion &#8216;,<br />
&#8216; quadrillion &#8216;,<br />
&#8216; quintillion &#8216;,<br />
&#8216; sextillion &#8216;,<br />
&#8216; septillion &#8216;,<br />
&#8216; octillion &#8216;,<br />
&#8216; nonillion &#8216;,<br />
&#8216; decillion &#8216;,<br />
&#8216; undecillion &#8216;,<br />
&#8216; duodecillion &#8216;<br />
);<br />
l_num      VARCHAR2 (50)   DEFAULT TRUNC (p_number);<br />
l_return   VARCHAR2 (4000);<br />
BEGIN<br />
FOR i IN 1 .. l_str.COUNT<br />
LOOP<br />
EXIT WHEN l_num IS NULL;</p>
<p>IF (TO_NUMBER (SUBSTR (l_num, LENGTH (l_num) &#8211; 2, 3)) &lt;&gt; 0)<br />
THEN<br />
l_return :=<br />
TO_CHAR (TO_DATE (SUBSTR (l_num, LENGTH (l_num) &#8211; 2, 3), &#8216;J&#8217;),<br />
&#8216;Jsp&#8217;<br />
)<br />
|| l_str (i)<br />
|| l_return;<br />
END IF;</p>
<p>l_num := SUBSTR (l_num, 1, LENGTH (l_num) &#8211; 3);<br />
END LOOP;</p>
<p>RETURN l_return;<br />
END spell_number;<br />
END spell_number_pkg;<br />
/</p>
Posted in Oracle Tagged: development, query <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=167&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2008/10/28/spell-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>
	</item>
		<item>
		<title>Use a FOR UPDATE Cursor</title>
		<link>http://ediyanto83.wordpress.com/2007/12/18/use-a-for-update-cursor/</link>
		<comments>http://ediyanto83.wordpress.com/2007/12/18/use-a-for-update-cursor/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 04:21:29 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/12/18/use-a-for-update-cursor/</guid>
		<description><![CDATA[The cursor FOR UPDATE clause is only used with a cursor when you want to update  tables in the database. Generally, when you execute a SELECT statement, you are  not locking any rows. The purpose of using the FOR UPDATE clause is to lock the  rows of the tables that you want [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=101&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The cursor FOR UPDATE clause is only used with a cursor when you want to update  tables in the database. Generally, when you execute a SELECT statement, you are  not locking any rows. The purpose of using the FOR UPDATE clause is to lock the  rows of the tables that you want to update, so that another user cannot perform  an update until you perform your update and release the lock. The next COMMIT or  ROLLBACK statement releases the lock. The FOR UPDATE clause will change the  manner in which the cursor operates in only a few respects. When you open a  cursor, all rows that meet the restriction criteria are identified as part of  the active set. Using the FOR UPDATE clause will lock these rows that have been  identified in the active set. If the FOR UPDATE clause is used, then rows may  not be fetched from the cursor until a COMMIT has been issued. It is important  for you to consider where to place the COMMIT.</p>
<p><span id="more-101"></span></p>
<p class="docText">The syntax is simply to add FOR UPDATE to the end of the cursor  definition. If there are multiple items being selected, but you only want to  lock one of them, then end the cursor definition with the following syntax:</p>
<pre>FOR UPDATE OF &lt;item_name&gt;   <strong>Example:</strong>

DECLARE

  CURSOR c_course IS

     SELECT course_no, cost

       FROM course FOR UPDATE;

BEGIN

   FOR r_course IN c_course

   LOOP

      IF r_course.cost &lt; 2500

      THEN

         UPDATE course

            SET cost = r_course.cost + 10

          WHERE course_no = r_course.course_no;

      END IF;

   END LOOP;

END;</pre>
<p class="docText">This example shows how to update the cost of all courses with a  cost under $2500. It will increment them by 10.</p>
<table border="0" cellpadding="0" cellspacing="16">
<tr valign="top">
<td class="docText" align="right">Q:</td>
<td>
<p class="docText">In the example just given, where should the COMMIT be placed?  What are the issues involved in deciding where to place a COMMIT in this  example?</p>
</td>
</tr>
</table>
<p class="docText"><span class="docEmphasis"><strong>Answer</strong>: Placing a COMMIT after each  update can be costly. But if there are a lot of updates and the COMMIT comes  after the block loop, then there is a risk of a rollback segment not being large  enough. Normally, the COMMIT would go after the loop, except when the  transaction count is high, and then you might want to code something that does a  COMMIT for each 10,000 records. If this were part of a large procedure, you may  want to put a SAVEPOINT after the loop. Then, if you need to rollback this  update at a later point, it would be an easy task.</span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/101/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/101/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=101&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/12/18/use-a-for-update-cursor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>
	</item>
		<item>
		<title>Reducing Loop Overhead for DML Statements and Queries (FORALL,BULK COLLECT)</title>
		<link>http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/#comments</comments>
		<pubDate>Thu, 31 May 2007 03:49:04 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/</guid>
		<description><![CDATA[PL/SQL sends SQL statements such as DML and queries to the SQL engine for execution, and SQL returns the result data to PL/SQL. You can minimize the performance overhead of this communication between PL/SQL and SQL by using the PL/SQL language features known collectively as bulk SQL. The FORALL statement sends INSERT, UPDATE, or DELETE [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=61&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>PL/SQL sends SQL statements such as DML and queries to the SQL engine for execution, and SQL returns the result data to PL/SQL. You can minimize the performance overhead of this communication between PL/SQL and SQL by using the PL/SQL language features known collectively as bulk SQL. The <strong>FORALL </strong>statement sends <em>INSERT</em>, <em>UPDATE</em>, or <em>DELETE </em>statements in batches, rather than one at a time. The <strong>BULK COLLECT</strong> clause brings back batches of results from SQL. If the DML statement affects four or more database rows, the use of bulk SQL can improve performance considerably.<span id="more-61"></span></p>
<ul>
<li><strong><em>Using the FORALL Statement</em></strong>, the keyword <strong>FORALL </strong>lets you run multiple DML statements very efficiently. It can only repeat a single DML statement, unlike a general-purpose <em>FOR </em>loop.<br />
The following example loads some data into PL/SQL collections. Then it inserts the<br />
collection elements into a database table twice: first using a <em>FOR </em>loop, then using a<br />
<strong>FORALL </strong>statement. The <strong>FORALL </strong>version is much faster.<br />
<a href="http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/for-all/" target="_blank" rel="attachment wp-att-62" title="For All"><img src="http://ediyanto83.files.wordpress.com/2007/05/forall.jpg" alt="For All" /><br />
</a></li>
<li><strong>Retrieving Query Results into Collections with the BULK COLLECT Clause, </strong>using the keywords <strong>BULK COLLECT </strong>with a query is a very efficient way to retrieve the result set. Instead of looping through each row, you store the results in one or more collections, in a single operation. You can use these keywords in the <em>SELECT INTO</em> and <em>FETCH INTO</em> statements, and the <em>RETURNING INTO</em> clause.With the <strong>BULK COLLECT</strong> clause, all the variables in the <strong>INTO</strong> list must be collections. The table columns can hold scalar or composite values, including object types. The following example loads two entire database columns into nested tables:<a href="http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/bulk-collect-clause/" target="_blank" rel="attachment wp-att-64" title="Bulk Collect Clause"><img src="http://ediyanto83.files.wordpress.com/2007/05/bulk_collect_clause.jpg" alt="Bulk Collect Clause" /></a></li>
</ul>
<p><font size="2">source: <em>PL/SQL User&#8217;s Guide and Reference 10g Release 1 (10.1)</em></font></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/61/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/61/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=61&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/31/reducing-loop-overhead-for-dml-statements-and-queries-forallbulk-collect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/forall.jpg" medium="image">
			<media:title type="html">For All</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/bulk_collect_clause.jpg" medium="image">
			<media:title type="html">Bulk Collect Clause</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic SQL with RETURNING BULK COLLECT INTO Clause</title>
		<link>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-returning-bulk-collect-into-clause/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-returning-bulk-collect-into-clause/#comments</comments>
		<pubDate>Fri, 25 May 2007 10:00:40 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-returning-bulk-collect-into-clause/</guid>
		<description><![CDATA[Only INSERT, UPDATE, and DELETE statements can have output bind variables. You bulk-bind them with the RETURNING BULK COLLECT INTO clause of EXECUTE IMMEDIATE. With this clause, you can see which data have been inserted, updated or deleted.

Example:
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=56&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Only INSERT, UPDATE, and DELETE statements can have output bind variables. You bulk-bind them with the RETURNING BULK COLLECT INTO clause of EXECUTE IMMEDIATE. With this clause, you can see which data have been inserted, updated or deleted.</p>
<p><span id="more-56"></span><br />
Example:<a href="http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-returning-bulk-collect-into-clause/bulk_returningjpg/" rel="attachment wp-att-57" title="bulk_returning.jpg"><img src="http://ediyanto83.files.wordpress.com/2007/05/bulk_returning.jpg" alt="bulk_returning.jpg" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=56&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-returning-bulk-collect-into-clause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/bulk_returning.jpg" medium="image">
			<media:title type="html">bulk_returning.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic SQL with BULK COLLECT INTO Clause</title>
		<link>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-bulk-collect-into-clause/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-bulk-collect-into-clause/#comments</comments>
		<pubDate>Fri, 25 May 2007 08:48:40 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-bulk-collect-into-clause/</guid>
		<description><![CDATA[Bulk SQL passes entire collections back and forth, not just individual elements. This technique improves performance by minimizing the number of context switches between the PL/SQL and SQL engines. You can use a single statement instead of aloop that issues a SQL statement in every iteration.
Bulk binding lets Oracle bind a variable in a SQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=52&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bulk SQL passes entire collections back and forth, not just individual elements. This technique improves performance by minimizing the number of context switches between the PL/SQL and SQL engines. You can use a single statement instead of aloop that issues a SQL statement in every iteration.</p>
<p>Bulk binding lets Oracle bind a variable in a SQL statement to a collection of values. The collection type can be any PL/SQL collection type (index-by table, nested table, or varray). The collection elements must have a SQL datatype such as CHAR, DATE, or NUMBER.<br />
<span id="more-52"></span>You can bind define variables in a dynamic query using the BULK COLLECT INTO clause. As the following example shows, you can use that clause in a bulk FETCH or bulk EXECUTE IMMEDIATE statement:</p>
<p><a href="http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-bulk-collect-into-clause/bulk_immediate_fetchjpg/" rel="attachment wp-att-55" title="bulk_immediate_fetch.jpg"><img src="http://ediyanto83.files.wordpress.com/2007/05/bulk_immediate_fetch.jpg" alt="bulk_immediate_fetch.jpg" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/52/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/52/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=52&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/25/dynamic-sql-with-bulk-collect-into-clause/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/bulk_immediate_fetch.jpg" medium="image">
			<media:title type="html">bulk_immediate_fetch.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Assigning Nested Tables with Set Operators</title>
		<link>http://ediyanto83.wordpress.com/2007/05/16/assigning-nested-tables-with-set-operators/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/16/assigning-nested-tables-with-set-operators/#comments</comments>
		<pubDate>Wed, 16 May 2007 02:54:56 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/16/assigning-nested-tables-with-set-operators/</guid>
		<description><![CDATA[The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=40&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span class="bodycopy"></span><span class="bodycopy">The SQL language has long offered the ability to apply set operations (</span><tt>UNION, INTERSECT</tt><span class="bodycopy">, and </span><tt>MINUS</tt><span class="bodycopy">) to the result sets of queries. In Oracle Database 10<em>g</em>, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.</span></p>
<p>Nested Table Function:</p>
<ul>
<li><strong>MULTISET UNION</strong>, all elements in both nested table x and nested table y are returned.  If tables x and y are both empty then the returned table will be empty.</li>
<li><strong>MULTISET INTERSECT</strong>, elements in nested table x that also appear in nested table y are returned. If tables x and y have no common elements the returned table will be empty.</li>
<li><strong>MULTISET EXCEPT</strong>, elements in nested table x that do not appear in nested table y are returned. If table x has no elements that are not in table y the returned table will be empty.</li>
<li><strong>SUBMULTISET OF</strong> and <strong>NOT SUBMULTISET OF</strong> compare two nested tables to determine if all elements in the first nested table also appear in second nested table. This function returns a Boolean value TRUE, FALSE or NULL. The key word OF is optional.</li>
</ul>
<p><span id="more-40"></span>The <strong>DISTINCT </strong>keyword in nested table function (MULTISET UNION, MULTISET INTERSECT, MULTISET EXCEPT)  eliminates duplicate elements from the results. Nested table x, y and the returned table must all be of the same type. If either x or y is null, then the returned table is null.</p>
<p><a href="http://ediyanto83.wordpress.com/2007/05/16/assigning-nested-tables-with-set-operators/nested_table_functionjpg/" rel="attachment wp-att-46" title="nested_table_function.jpg"><img src="http://ediyanto83.files.wordpress.com/2007/05/nested_table_function.jpg" alt="nested_table_function.jpg" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=40&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/16/assigning-nested-tables-with-set-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/nested_table_function.jpg" medium="image">
			<media:title type="html">nested_table_function.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Possible Exceptions for Collection Assignments</title>
		<link>http://ediyanto83.wordpress.com/2007/05/15/possible-exceptions-for-collection-assignments/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/15/possible-exceptions-for-collection-assignments/#comments</comments>
		<pubDate>Tue, 15 May 2007 05:23:05 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/15/possible-exceptions-for-collection-assignments/</guid>
		<description><![CDATA[Assigning a value to a collection element can cause various exceptions:

If the subscript is null or is not convertible to the right datatype, PL/SQL raises the predefined exception VALUE_ERROR. Usually, the subscript must be an integer. Associative arrays can also be declared to have VARCHAR2 subscripts.
 If the subscript refers to an uninitialized element, PL/SQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=38&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Assigning a value to a collection element can cause various exceptions:</p>
<ul>
<li>If the subscript is null or is not convertible to the right datatype, PL/SQL raises the predefined exception <strong>VALUE_ERROR</strong>. Usually, the subscript must be an integer. Associative arrays can also be declared to have VARCHAR2 subscripts.</li>
<li> If the subscript refers to an uninitialized element, PL/SQL raises <strong>SUBSCRIPT_BEYOND_COUNT</strong>.</li>
<li>If the collection is atomically null, PL/SQL raises <strong>COLLECTION_IS_NULL</strong> (Refence to uninitialized collection).</li>
</ul>
<p><span id="more-38"></span><a href="http://ediyanto83.wordpress.com/2007/05/15/possible-exceptions-for-collection-assignments/exceptions-for-collections/" rel="attachment wp-att-39" title="Exceptions for Collections"><img src="http://ediyanto83.files.wordpress.com/2007/05/collections.jpg" alt="Exceptions for Collections" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=38&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/15/possible-exceptions-for-collection-assignments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>

		<media:content url="http://ediyanto83.files.wordpress.com/2007/05/collections.jpg" medium="image">
			<media:title type="html">Exceptions for Collections</media:title>
		</media:content>
	</item>
		<item>
		<title>Exit Early from Nested FOR Loop</title>
		<link>http://ediyanto83.wordpress.com/2007/05/14/exit-early-from-nested-for-loop/</link>
		<comments>http://ediyanto83.wordpress.com/2007/05/14/exit-early-from-nested-for-loop/#comments</comments>
		<pubDate>Mon, 14 May 2007 09:49:41 +0000</pubDate>
		<dc:creator>Edi Yanto</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/05/14/exit-early-from-nested-for-loop/</guid>
		<description><![CDATA[If you want to exit from any enclosing loop, but not just the current loop, you can label the enclosing loop and use the label in an EXIT statement.
&#60;&#60;outer&#62;&#62;
FOR i IN 1..5 LOOP
. . . . .
FOR j IN 1..10 LOOP
. . . . .
EXIT outer WHEN . . . .
. . . . .
END [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=37&subd=ediyanto83&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you want to exit from any enclosing loop, but not just the current loop, you can label the enclosing loop and use the label in an <strong>EXIT </strong>statement.</p>
<p>&lt;&lt;outer&gt;&gt;<br />
FOR i IN 1..5 LOOP<br />
. . . . .<br />
FOR j IN 1..10 LOOP<br />
. . . . .<br />
EXIT outer WHEN . . . .<br />
. . . . .<br />
END LOOP;<br />
END LOOP outer;<br />
. . . . .</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ediyanto83.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ediyanto83.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ediyanto83.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ediyanto83.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ediyanto83.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ediyanto83.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ediyanto83.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ediyanto83.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ediyanto83.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ediyanto83.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ediyanto83.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ediyanto83.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ediyanto83.wordpress.com&blog=848929&post=37&subd=ediyanto83&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ediyanto83.wordpress.com/2007/05/14/exit-early-from-nested-for-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a46483722032898c6cbfab66b430a214?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Edi</media:title>
		</media:content>
	</item>
	</channel>
</rss>