<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My World &#187; Oracle &amp; PL/SQL Stuff</title>
	<atom:link href="http://sathyabh.at/category/programming/oracle-plsql-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>http://sathyabh.at</link>
	<description>A Blog On All The Things That Happen In My Life</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:41:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fix Initialization Error: LoadLibrary oci.dll returned 0 while trying to connect to Oracle using PL/SQL Developer</title>
		<link>http://sathyabh.at/2011/03/21/fix-initialization-error-loadlibrary-oci-dll-returned-0-while-trying-to-connect-to-oracle-using-plsql-developer/</link>
		<comments>http://sathyabh.at/2011/03/21/fix-initialization-error-loadlibrary-oci-dll-returned-0-while-trying-to-connect-to-oracle-using-plsql-developer/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 08:38:24 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[instant client]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[PL/SQL Developer]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=462</guid>
		<description><![CDATA[Quick post: I was trying to connect to a 64-bit Oracle database using PL/SQL Developer. Despite ORACLE_HOME being set the right values and oci.dll available, PL/SQL Developer could not connect to the database. Further probing indicated that the Oracle installation was a 64-bit one, and PL/SQL Developer is incapable of loading 64-bit version of oci.dll [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/' rel='bookmark' title='Making Oracle Forms Use JRE instead of Jinitiator'>Making Oracle Forms Use JRE instead of Jinitiator</a></li>
<li><a href='http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/' rel='bookmark' title='Download Toad for Oracle for Free'>Download Toad for Oracle for Free</a></li>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2011%252F03%252F21%252Ffix-initialization-error-loadlibrary-oci-dll-returned-0-while-trying-to-connect-to-oracle-using-plsql-developer%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fu.sbhat.me%2FfP78nY%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Fix%20Initialization%20Error%3A%20LoadLibrary%20oci.dll%20returned%200%20while%20trying%20to%20connect%20to%20Oracle%20using%20PL%2FSQL%20Developer%22%20%7D);"></div>
<p>Quick post: I was trying to connect to a 64-bit Oracle database using PL/SQL Developer. Despite ORACLE_HOME being set the right values and oci.dll available, PL/SQL Developer could not connect to the database.</p>
<p><span id="more-462"></span></p>
<p>Further probing indicated that the Oracle installation was a 64-bit one, and PL/SQL Developer is incapable of loading 64-bit version of oci.dll file. To fix this, download the 32-bit version of <a href="http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html">Oracle Instant Client</a>, extract it to a directory such as \instant_client.</p>
<p>Next, configure PL/SQL Developer to use this version by clicking on Tool menus -&gt; Preferences. Under Oracle Home, point to the location where you had extracted Instant client (\instant_client, in this case)  and under location of OCI Library, point to the oci.dll file present in location where you had extracted Instant client ( \instant_client\oci.dll). Restart PL/SQL Developer and you should be able to connect now.</p>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/' rel='bookmark' title='Making Oracle Forms Use JRE instead of Jinitiator'>Making Oracle Forms Use JRE instead of Jinitiator</a></li>
<li><a href='http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/' rel='bookmark' title='Download Toad for Oracle for Free'>Download Toad for Oracle for Free</a></li>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2011/03/21/fix-initialization-error-loadlibrary-oci-dll-returned-0-while-trying-to-connect-to-oracle-using-plsql-developer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making Oracle Forms Use JRE instead of Jinitiator</title>
		<link>http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/</link>
		<comments>http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 20:50:47 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Application Server]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[Oracle Forms]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=424</guid>
		<description><![CDATA[By default, Oracle Forms Application Server serves Oracle Forms applications using the built-in Jinitiator JVM. While JVM works swell with cutting edge browsers1 it pretty much crashes most of the other browsers2 and doesn&#8217;t work at all in Chrome. There are workarounds but the workarounds do not play well while working with multiple tabs. Here&#8217;s [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/' rel='bookmark' title='Fixing Internet Explorer Crash on Launching Oracle Forms Application with jInitiator'>Fixing Internet Explorer Crash on Launching Oracle Forms Application with jInitiator</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/' rel='bookmark' title='Download Toad for Oracle for Free'>Download Toad for Oracle for Free</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2010%252F12%252F01%252Fmaking-oracle-forms-use-jre-instead-of-jinitiator%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fu.sbhat.me%2Fg7WwQK%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Making%20Oracle%20Forms%20Use%20JRE%20instead%20of%20Jinitiator%22%20%7D);"></div>
<p>By default, Oracle Forms Application Server serves Oracle Forms applications using the built-in <a href="http://en.wikipedia.org/wiki/Jinitiator">Jinitiator JVM</a>. While JVM works <em>swell </em>with cutting edge browsers<sup><a href="http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/#footnote_0_424" id="identifier_0_424" class="footnote-link footnote-identifier-link" title="IE6">1</a></sup> it pretty much crashes most of the other browsers<sup><a href="http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/#footnote_1_424" id="identifier_1_424" class="footnote-link footnote-identifier-link" title="Firefox, IE7+">2</a></sup> and doesn&#8217;t work at all in Chrome. There <a href="http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/" target="_blank">are workarounds</a> but the workarounds do not play well while working with multiple tabs.</p>
<p><span id="more-424"></span></p>
<p>Here&#8217;s a simple way to make the Application Server serve Oracle Forms Applications using JRE rather than the Jinitiator. Please remember to take a backup of your existing files!</p>
<p>Locate your formsweb.cfg file. It should be in $oracle_home/forms/server directory. Add the below lines to the section corresponding to your config= setting.</p>
<pre class="brush:bash">baseHTMLjinitiator=basejpi.htm
jpi_download_page=http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html
jpi_classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93
jpi_codebase=https://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab
jpi_mimetype=application/x-java-applet;version=1.4.2</pre>
<p>Here&#8217;s a brief explanation of each of these terms:</p>
<ul>
<li>jpi_classid – The ClassID of the Sun JVM to use (Internet Explorer specific). Should be set to clsid:8AD9C840-044E-11D1-B3E9-00805F499D93 for dynamic versioning or to clsid:CAFEEFAC-&lt;major version&gt;-&lt;minor version&gt;-&lt;patch version&gt;-ABCDEFFEDCBA for static versioning</li>
<li>jpi_codebase – Download location of the CAB file for the Sun JVM (IE specific)</li>
<li>jpi_mimetype – JPI_MIMETYPE is a mime-type in a format like “application/x-java-applet;&lt;version_type&gt;=&lt;implementation_version&gt;”. For static versioning, &lt;version_type&gt; should be set to “jpi-version”. For dynamic versioning, this should be set to “version”.</li>
<li>jpi_download_page – This is the URL where Netscape/Firefox users can download the JRE.</li>
</ul>
<p>Refer <a href="http://www.oratransplant.nl/2005/05/24/settings-for-dynamic-versioning-with-sun-jpi-and-oracle-forms/">here</a> for a detailed explanation of each of these terms. That&#8217;s about it. Reloading the application should result in the JRE kicking in, rather than Jinitiator. Also ensure any jar files that you have are digitally signed, else you will run into an warning about blocking unsigned jar files which might lead to a showstopper bug.</p>

<ol class="footnotes"><li id="footnote_0_424" class="footnote">IE6</li><li id="footnote_1_424" class="footnote">Firefox, IE7+</li></ol><p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/' rel='bookmark' title='Fixing Internet Explorer Crash on Launching Oracle Forms Application with jInitiator'>Fixing Internet Explorer Crash on Launching Oracle Forms Application with jInitiator</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/' rel='bookmark' title='Download Toad for Oracle for Free'>Download Toad for Oracle for Free</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2010/12/01/making-oracle-forms-use-jre-instead-of-jinitiator/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Swap Table Names Between Inserts And Selects on the Same Line using Regular Expressions</title>
		<link>http://sathyabh.at/2010/10/04/swap-table-names-between-inserts-and-selects-on-the-same-line-using-regular-expressions/</link>
		<comments>http://sathyabh.at/2010/10/04/swap-table-names-between-inserts-and-selects-on-the-same-line-using-regular-expressions/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 00:14:28 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[swap table names]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=389</guid>
		<description><![CDATA[Background: For the past few days weeks, I have been working on a way to export selective data from one schema to import into another. Now the problem is that &#8220;selective&#8221; data refers to the data as stored across various tables in the custom application that I&#8217;ve been working on, with elaborate relational links between [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2010%252F10%252F04%252Fswap-table-names-between-inserts-and-selects-on-the-same-line-using-regular-expressions%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2F9PSFcG%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Swap%20Table%20Names%20Between%20Inserts%20And%20Selects%20on%20the%20Same%20Line%20using%20Regular%20Expressions%22%20%7D);"></div>
<p>Background: For the past few <span style="text-decoration: line-through;">days</span> weeks, I have been working on a way to export selective data from one schema to import into another. Now the problem is that &#8220;selective&#8221; data refers to the data as stored across various tables in the custom application that I&#8217;ve been working on, with elaborate relational links between the tables ( if you&#8217;re curious, the table count on the related data was about 65) &#8211; so it was not just couple of tables that I had to export.<br />
<span id="more-389"></span></p>
<p>So after exploring few alternatives, I concluded that the best way is fetch the related data into the &#8220;export versions&#8221; of these tables, dump these tables using Oracle&#8217;s export tool and re-import them.</p>
<p>Creating the export script wasn&#8217;t that difficult but a rather tedious task. The exports scripts look like</p>
<pre class="brush:sql">DROP TABLE TABLE_NAME1_EXP;
CREATE TABLE_NAME1_EXP AS SELECT * FROM TABLE_NAME1 WHERE_CONDITION;

DROP TABLE TABLE_NAME2_EXP;
CREATE TABLE_NAME2_EXP AS SELECT * FROM TABLE_NAME2 WHERE_CONDITION;

DROP TABLE TABLE_NAME3_EXP;
CREATE TABLE_NAME3_EXP AS SELECT * FROM TABLE_NAME3 WHERE_CONDITION;

DROP TABLE TABLE_NAME4_EXP;
CREATE TABLE_NAME4_EXP AS SELECT * FROM TABLE_NAME4 WHERE_CONDITION;</pre>
<p>&#8230; n times.</p>
<p>Once the export script was ready, added it to batch file which would ask for username, password &amp; service name so as to make it fully automated. Proceeded with testing, then I realized &#8211; to test this end to end, I needed to import the data back in &#8211; and I didn&#8217;t have an import script.</p>
<p>The import script would be the same as the export script, just the source and destination table names swapped, and without the DROP statements either.</p>
<p>So first thing to do was to get rid of the DROP statements. I figured regular expressions would be the best way to get rid of them, and with my rudimentary regexp experience I used Notepad++ ( I &lt;3 Notepad++ ) to remove them &#8211; I used the expression</p>
<pre class="brush:sql">DROP TABLE \w*;</pre>
<p>and replaced it with a space. So that solved my one problem.</p>
<p>Now when it came to part of swapping, I was absolutely clueless as to how to go about doing this. So dropped by <a id="aptureLink_obPD5AwJlF" href="http://chat.meta.stackoverflow.com/rooms/224/the-roach-motel">The Roach Motel</a>.</p>
<p>In case you&#8217;re wondering what &#8220;The Roach Motel&#8221; is &#8211; it&#8217;s a room setup within the insanely awesome <a id="aptureLink_rJQCbOcOpE" href="http://chat.meta.stackoverflow.com/">Stack Overflow Chat</a> for the purpose of Code Review and help with bug fixing. Got in touch with Josh, and he was able to whip out a <a id="aptureLink_lmcgQphmfo" href="http://jsfiddle.net/M6dxn/1/">quick solution</a> using jsfiddle. This saved me atleast 6 hours of tedious work.  I&#8217;m immensely grateful to <a id="aptureLink_S6fjAouQRp" href="http://meta.stackoverflow.com/users/131541?tab=accounts#tab-top">Josh</a> for all the help provided by him.</p>
<p>Here&#8217;s the solution:</p>
<p>An HTML Form:</p>
<pre class="brush:html">

<textarea id="sathyasql" cols="40" rows="20"></textarea>
<input id="go" type="submit" />
</pre>
<p>JS code for regexp find &amp; replace</p>
<pre class="brush:js">$('go').observe('click',function()
           {
              var sql = $F('sathyasql');
               sql = sql.replace(/INSERT INTO ([^ ]+) AS SELECT \* FROM ([^ ]+)/g,'INSERT INTO $2 AS SELECT * FROM $1');
              $('sathyasql').update(sql).value = sql;
           });
</pre>
<p>For those interested, full <a id="aptureLink_8lQS41Ofmn" href="http://chat.meta.stackoverflow.com/transcript/message/208874#208874">transcript</a> of my discussions with Josh</p>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2010/10/04/swap-table-names-between-inserts-and-selects-on-the-same-line-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Golden Rules for Developers</title>
		<link>http://sathyabh.at/2010/06/15/golden-rules-for-developers/</link>
		<comments>http://sathyabh.at/2010/06/15/golden-rules-for-developers/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 00:27:56 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PL/SQL]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=365</guid>
		<description><![CDATA[Steven Feuerstein has a nice little presentation on some golden rules for developers. They aren&#8217;t anything new, yet not many people read/follow them Download the PDF from here, or just read it via the embedded doc No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2010%252F06%252F15%252Fgolden-rules-for-developers%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FcDsweb%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Golden%20Rules%20for%20Developers%22%20%7D);"></div>
<p>Steven Feuerstein has a nice little presentation on some golden rules for developers. They aren&#8217;t anything new, yet not many people read/follow them <img src='http://sathyabh.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Download the PDF from <a href="http://www.toadworld.com/Portals/0/stevenf/Golden%20Rules%20for%20Developers.pdf" target="_blank">here</a>, or just read it via the embedded doc</p>
<p><a id="aptureLink_3yStRfMwMO" style="margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; text-align: center; display: inline !important; padding-top: 0px; padding-right: 6px; padding-bottom: 0px; padding-left: 6px;" href="http://www.toadworld.com/Portals/0/stevenf/Golden%20Rules%20for%20Developers.pdf"><img style="border: 0px initial initial;" title="Golden Rules for Developers" src="http://placeholder.apture.com/ph/660x390_ScribdByUrlItem/" alt="" width="660px" height="390px" /></a></p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2010/06/15/golden-rules-for-developers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Download Toad for Oracle for Free</title>
		<link>http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/</link>
		<comments>http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/#comments</comments>
		<pubDate>Fri, 28 May 2010 01:47:56 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Views]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[PL/SQL Developer]]></category>
		<category><![CDATA[SQL Developer]]></category>
		<category><![CDATA[TOADL]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=356</guid>
		<description><![CDATA[Toad (acronym for Tool for Oracle Application Developers) is arguably one of the most popular and best known tools used by most people dabbling in Oracle databases ( or for that matter, most relational databases anyway). Toad&#8217;s reputation is so good, I&#8217;ve known few people swear by it and don&#8217;t even bother looking at other [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2009/09/04/save-250-when-installing-or-upgrading-to-microsoft-visual-studio-professional-edition/' rel='bookmark' title='Save $250 when installing or upgrading to Microsoft Visual Studio Professional Edition!'>Save $250 when installing or upgrading to Microsoft Visual Studio Professional Edition!</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2008/05/02/coldplay-releases-their-first-song-for-download/' rel='bookmark' title='Coldplay Releases Their First Song For Download'>Coldplay Releases Their First Song For Download</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2010%252F05%252F28%252Fdownload-toad-for-oracle-for-free%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FbJt36X%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Download%20Toad%20for%20Oracle%20for%20Free%22%20%7D);"></div>
<p>Toad (acronym for Tool for Oracle Application Developers) is arguably one of the most popular and best known tools used by most people dabbling in Oracle databases ( or for that matter, most relational databases anyway). Toad&#8217;s reputation is so good, I&#8217;ve known few people swear by it and don&#8217;t even bother looking at other software, no matter how good.</p>
<p>Toad&#8217;s got more features than your average SQL/ PL/SQL developer would use,and hence got a bit of a steep learning curve. Not to mention an even steeper price tag ( the base edition starts at $957, and goes all the way upto $4709 if you include the Code Tester and DB Admin module). Given these prices, Toad is pretty heavily pirated.</p>
<p>However, most people are unaware that Toad also comes in a <a id="aptureLink_4cKDhVj5ka" href="http://www.toadworld.com/DOWNLOADS/Freeware/ToadforOracleFreeware/tabid/558/Default.aspx">freeware edition</a>, and until recently was severely crippled. Few days ago, there was an update to Toad freeware &#8211; and the updates are pretty good. The freeware edition is now based on 10.5 codebase, rather than previous 8.5 codebase. Now before you start jumping up and down, the restrictions on the freeware edition are still in place, but noticeably lesser than the previous update. Some of the restrictions include you being limited to only one concurrent database connection (which btw &#8211; would severely hamper me, I generally maintain 2-3 connections). Another major irritation is that the freeware edition will expire every 90 days, and you will need to <a id="aptureLink_LAehWNNLjw" href="http://www.toadworld.com/DOWNLOADS/Freeware/ToadforOracleFreeware/tabid/558/Default.aspx">uninstall, re-download and reinstall it</a>. Ugh.</p>
<p>Here&#8217;s comparison chart between the commercial edition and freeware.</p>
<p><a id="aptureLink_DLgVL66flm" style="margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; text-align: center; display: inline !important; padding-top: 0px; padding-right: 6px; padding-bottom: 0px; padding-left: 6px;" href="http://www.toadworld.com/Portals/0/ToadOracle/Toad%20Commercial%20vs%20Freeware%2010.5%20Basic%20Functionality.pdf"><img style="border: 0px initial initial;" title="Toad Freeware edition v/s Commercial edition comparison" src="http://placeholder.apture.com/ph/660x390_ScribdByUrlItem/" alt="" width="660px" height="390px" /></a></p>
<p>If you&#8217;re OK with the restrictions imposed by freeware edition or a Toad fan, then you can go ahead with getting it. If you ask me, Oracle&#8217;s SQL Developer is a perfectly acceptable alternative tool.</p>
<p>(In case you&#8217;re wondering my preferred tool, its <a id="aptureLink_ifURiVhg88" href="http://www.allroundautomations.com/plsqldev.html">Allround Automations&#8217; PL/SQL Developer</a>. Yes, yes, I know, the UI is butt ugly &#8211; I didn&#8217;t want to touch it at all just because of the UI &#8211; but believe me, once you get over the UI, you&#8217;ll love it &#8211; its fantastically fast, consumes very little memory and got boat load of features for the price its available at. I&#8217;ll probably do a review of the tool soon.)</p>
<p>Do let me know if you have a preferred /alternative tool that I could look at.</p>
<p>Download Links:</p>
<p>1. <a id="aptureLink_kYQYFLbnw4" href="http://www.toadworld.com/DOWNLOADS/Freeware/ToadforOracleFreeware/tabid/558/Default.aspx">Toad Freeware edition</a></p>
<p>2. <a id="aptureLink_QGaPBjQ0kP" href="http://www.oracle.com/technology/products/database/sql_developer/index.html">Oracle SQL Developer</a></p>
<p>3. <a id="aptureLink_fXd7AqwuHo" href="http://www.allroundautomations.com/plsqldev.html">Allround Automations PL/SQL Developer</a></p>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2009/09/04/save-250-when-installing-or-upgrading-to-microsoft-visual-studio-professional-edition/' rel='bookmark' title='Save $250 when installing or upgrading to Microsoft Visual Studio Professional Edition!'>Save $250 when installing or upgrading to Microsoft Visual Studio Professional Edition!</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2008/05/02/coldplay-releases-their-first-song-for-download/' rel='bookmark' title='Coldplay Releases Their First Song For Download'>Coldplay Releases Their First Song For Download</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2010/05/28/download-toad-for-oracle-for-free/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Brush up your PL/SQL knowledge with PL/SQL Challenge</title>
		<link>http://sathyabh.at/2010/05/10/brush-up-your-plsql-knowledge-with-plsql-challenge/</link>
		<comments>http://sathyabh.at/2010/05/10/brush-up-your-plsql-knowledge-with-plsql-challenge/#comments</comments>
		<pubDate>Mon, 10 May 2010 05:14:31 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=353</guid>
		<description><![CDATA[If you&#8217;re looking to brush up on your PL/SQL knowledge, PL/SQL challenge is pretty nice. It&#8217;s a daily challenge quiz, where you are presented with  multiple choice or true/false questions. It&#8217;s an initiative by Steven Feuerstein , who&#8217;s pretty well known. I just joined in, first few questions were not too tough Join in, there&#8217;s [...]
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2010%252F05%252F10%252Fbrush-up-your-plsql-knowledge-with-plsql-challenge%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FbqZdcS%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Brush%20up%20your%20PL%2FSQL%20knowledge%20with%20PL%2FSQL%20Challenge%22%20%7D);"></div>
<p>If you&#8217;re looking to brush up on your PL/SQL knowledge, <a id="aptureLink_bTi5ZytYmL" href="http://plsqlchallenge.com/pls/apex/f?p=10000:27:2661386768578984::NO:::">PL/SQL challenge</a> is pretty nice. It&#8217;s a daily challenge quiz, where you are presented with  multiple choice or true/false questions. It&#8217;s an initiative by <a href="http://en.wikipedia.org/wiki/Steven_Feuerstein" target="_blank">Steven Feuerstein</a> <a href="http://en.wikipedia.org/wiki/Steven_Feuerstein" target="_blank"></a>, who&#8217;s pretty well known. I just joined in, first few questions were not too tough <img src='http://sathyabh.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Join in, there&#8217;s <a id="aptureLink_WlOD3WAo4T" href="http://plsqlchallenge.com/pls/apex/f?p=10000:28:2661386768578984::NO:::">some great prizes to be won</a> .</p>
<p>If you know of any more such websites, do drop in a comment and let me know.</p>
<p>(PS: If you&#8217;re wondering what&#8217;s with the weird URL structure, well its built on <a id="aptureLink_rW2c7dSIBL" href="http://en.wikipedia.org/wiki/Oracle%20Application%20Express">Oracle Apex</a>. Long, clumsy URLs are a pain, and Apex does nothing to banish them).</p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2010/05/10/brush-up-your-plsql-knowledge-with-plsql-challenge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fixing Internet Explorer Crash on Launching Oracle Forms Application with jInitiator</title>
		<link>http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/</link>
		<comments>http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 21:29:20 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[jinitiator]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=262</guid>
		<description><![CDATA[I&#8217;ve been facing this really annoying problem for quite some time now. My job revolves around developing apps using Oracle Forms Builder. Oracle Forms applications, uses Java applets to run inside any browser, on most platforms. Here&#8217;s the kink &#8211; Oracle Forms applications by default uses Oracle&#8217;s jInitiator which is a JVM made by Oracle and allows a web enabled Oracle Forms client application to [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2009%252F06%252F27%252Ffixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Fixing%20Internet%20Explorer%20Crash%20on%20Launching%20Oracle%20Forms%20Application%20with%20jInitiator%22%20%7D);"></div>
<p>I&#8217;ve been facing this really annoying problem for quite some time now. My job revolves around developing apps using <a id="aptureLink_dzpThUVtnA" href="http://en.wikipedia.org/wiki/Oracle%20Forms">Oracle Forms Builder</a>. Oracle Forms applications, uses Java applets to run inside any browser, on most platforms. Here&#8217;s the kink &#8211; Oracle Forms applications by default uses <a id="aptureLink_5VcUe7aCHj" href="http://en.wikipedia.org/wiki/Oracle%20Corporation">Oracle&#8217;s</a> <a id="aptureLink_uyXnIMpqB7" href="http://en.wikipedia.org/wiki/Jinitiator">jInitiator</a> which is a JVM made by Oracle and allows a web enabled <a style="text-decoration: none; background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; color: #5a3696; background-position: initial initial;" title="Oracle Forms" href="http://en.wikipedia.org/wiki/Oracle_Forms">Oracle Forms</a> client application to be run inside a web browser.</p>
<p>As much as I hate using Internet Explorer &#8211; I have to depend on it as the my app depends on other components which are designed on run on Internet Explorer only <img src='http://sathyabh.at/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' />  </p>
<p>Till now I&#8217;ve been using Mozilla Firefox, but now the situation demands that I needed to use Internet Explorer. And when I launched Internet Explorer &#8211; Ka boom! Internet Explorer crashes. Did few things, such as disabling all addons, getting rid of Sun&#8217;s JVM et al, but made no difference.</p>
<p>[ad]</p>
<p>Finally, I came across a solution(or rather a workaround) &#8211; replace the jvm.dll in jinitiator directory with that present in Sun&#8217;s JRE 1.6. If you don&#8217;t want to install the whole bundle &#8211; just <a id="aptureLink_xEBjE1aaLa" href="http://files.getdropbox.com/u/3353/jvm.dll">click here</a>(jvm.dll, 2.2 MB), I&#8217;ve uploaded just the jvm.dll file, rename the original jvm.dll (present in jinitiator/bin/hotspot directory) to, say jvm.dll.old, and replace it with the one given in the above link. Restart the browser, IE shouldn&#8217;t crash anymore.</p>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2009/06/27/fixing-internet-explorer-crash-on-launching-oracle-forms-application-with-jinitiator/feed/</wfw:commentRss>
		<slash:comments>214</slash:comments>
		</item>
		<item>
		<title>The Power and Simplicity of Oracle Hierarchical Queries</title>
		<link>http://sathyabh.at/2009/01/19/the-power-and-simplicity-of-oracle-hierarchical-queries/</link>
		<comments>http://sathyabh.at/2009/01/19/the-power-and-simplicity-of-oracle-hierarchical-queries/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 04:12:55 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[hierarchical queries]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=208</guid>
		<description><![CDATA[They say &#8220;Necessity is the Power of Invention&#8221; &#8211; a quote which I fully understood the impact today. I&#8217;ve been trying to understand Oracle&#8217;s Hierarchical Queries for a while now, but never fully understood the situation under which or when it would be used. Yesterday I got a reason to use it. Let me begin. [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2008/06/24/query-for-displaying-the-calender-of-the-current-year-using-sql/' rel='bookmark' title='Query For Displaying The Calender of The Current Year using SQL'>Query For Displaying The Calender of The Current Year using SQL</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2009%252F01%252F19%252Fthe-power-and-simplicity-of-oracle-hierarchical-queries%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22The%20Power%20and%20Simplicity%20of%20Oracle%20Hierarchical%20Queries%22%20%7D);"></div>
<p>They say &#8220;Necessity is the Power of Invention&#8221; &#8211; a quote which I fully understood the impact today. I&#8217;ve been trying to understand Oracle&#8217;s Hierarchical Queries for a while now, but never fully understood the situation under which or when it would be used. Yesterday I got a reason to use it. Let me begin.</p>
<p style="text-align: left;"><span id="more-208"></span><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/menu.png"><img class="size-medium wp-image-209 aligncenter" title="menu" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/menu-300x178.png" alt="menu" width="300" height="178" /></a>The above picure shows the menu structure of the our application. Now the implementer wanted the menu structure, of each and _every_ module, in a spreadsheet so that he could forward it to the client and get the user authorization thing going(ie, who&#8217;s got authority to view/edit etc). Now under each module we have several menus and submenus, and manually entering these would be like ultimate FAIL (later ananlysis showed on an average, each module had about 80 entries). So I was figuring out how to extract this. Now I knew that all these entries were there in the database I was struggling with the query to extract it.</p>
<p>So the first query I came up was this:</p>
<p><code><span style="font-family: Courier New; font-size: 10pt;"><br />
<span style="color: blue; ">SELECT</span> <span style="color: maroon; ">MENU_SCR_NAME</span><br />
<span style="color: blue; ">FROM</span> <span style="color: maroon; ">MENU_MENUS</span><br />
<span style="color: blue; ">WHERE</span> <span style="color: maroon; ">MENU_PARENT_ID</span> <span style="color: silver; ">=</span> <span style="color: red; ">'101'</span></span></code></p>
<p>This is what the query results were &#8211; a simple output.</p>
<p><span style="font-family: Courier New; font-size: 10pt;"><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query1.png"><img class="alignnone size-full wp-image-211" title="Query results" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query1.png" alt="Query results" width="180" height="338" /></a></span></p>
<p>Now I knew I&#8217;d be going nowhere with this simple query, and I knew normal joins won&#8217;t work, so I started looking at Hierarchical queries. Hierarchical queries(going to refer as h-queries) basically allow you to build queries, based on well, hierarchies. Parent &#8211; Child Relationships. Tree-Leaf style. Read a bit on h-queries and reconstructed the SQL query to the one below.</p>
<p><code><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">SELECT</span> <span style="color: maroon;">MENU_SCR_NAME</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">MENU_MENUS</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">MENU_ID</span> <span style="color: silver;">=</span> <span style="color: maroon;">MENU_PARENT_ID</span><br />
<span style="color: blue;">START</span> <span style="color: blue;">WITH</span> <span style="color: maroon;">MENU_ID</span> <span style="color: silver;">=</span> <span style="color: red;">'101'</span><span style="color: silver;">;</span><br />
</span></code><br />
The result of the query is shown below:</p>
<p><span style="font-family: Courier New; font-size: 10;"><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query2.png"><img class="alignnone size-full wp-image-212" title="query2" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query2.png" alt="query2" width="215" height="350" /></a></span></p>
<p>While the result of the query looks the same as the first, I knew that it was returning the results in a hierarchy,just check the first image. The keyword for this query is &#8220;Connect by&#8221; and &#8220;Prior&#8221; which transforms the query into a h-query. The &#8220;connect by&#8221; and &#8220;prior&#8221; gives the conditions for hierarachy in the query, with the column next to &#8220;prior&#8221; being the child column and the one next to equality being the parent column. The &#8220;start with&#8221; keyword tells Oracle which is the root record.</p>
<p>Now make things a little complicated, the database contains more records than what&#8217;s necessary, and I had to filter them based on user authorization conditions as well. So I added a subquery to filter out those records which belong to the superuser.</p>
<p>So the query now became a little bit more (unnecessarily) complicated:<br />
<code><br />
<span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">SELECT</span> <span style="color: #ff0080;"><strong>Lpad</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: silver;">,</span><span style="color: #ff0080;"><strong>Length</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: maroon;">)</span> <span style="color: silver;">+</span> <span style="color: blue;">LEVEL</span> <span style="color: silver;">*</span> <span style="color: black;">4</span> <span style="color: silver;">-</span> <span style="color: black;">4</span><span style="color: silver;">,</span><span style="color: red;">'-'</span><span style="color: maroon;">)</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">menu_id</span> <span style="color: blue;">IN</span> <span style="color: maroon;">(</span><span style="color: blue;">SELECT</span> <span style="color: maroon;">um_menu_id</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_user_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">um_group_id</span> <span style="color: silver;">=</span> <span style="color: red;">'USGRP'</span><br />
<span style="color: blue;">AND</span> <span style="color: maroon;">um_menu_id</span> <span style="color: blue;">IN</span> <span style="color: maroon;">(</span><span style="color: blue;">SELECT</span> <span style="color: maroon;">menu_id</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_menus</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: maroon;">menu_parent_id</span><br />
<span style="color: blue;">START</span> <span style="color: blue;">WITH</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: red;">'101'</span><span style="color: maroon;">)</span><span style="color: maroon;">)</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: maroon;">menu_parent_id</span><br />
<span style="color: blue;">ORDER</span> <span style="color: blue;">BY</span> <span style="color: maroon;">menu_id</span><br />
</span></code><br />
The Lpad function is an Oracle PL/SQL  function which adds padding of a specified character to the left. The results were not exactly what I was looking for.</p>
<p><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query3.png"><img class="alignnone size-full wp-image-216" title="query3" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query3.png" alt="query3" width="160" height="360" /></a></p>
<p>A bit of further reading and I came to know that order by destroys the hierarchy, and &#8220;order siblings&#8221; by is what is supported to be used.</p>
<p>So Modified the query to:<br />
<code><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">SELECT</span> <span style="color: #ff0080;"><strong>Lpad</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: silver;">,</span><span style="color: #ff0080;"><strong>Length</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: maroon;">)</span> <span style="color: silver;">+</span> <span style="color: blue;">LEVEL</span> <span style="color: silver;">*</span> <span style="color: black;">4</span> <span style="color: silver;">-</span> <span style="color: black;">4</span><span style="color: silver;">,</span><span style="color: red;">'-'</span><span style="color: maroon;">)</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">menu_id</span> <span style="color: blue;">IN</span> <span style="color: maroon;">(</span><span style="color: blue;">SELECT</span> <span style="color: maroon;">um_menu_id</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_user_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">um_group_id</span> <span style="color: silver;">=</span> <span style="color: red;">'USGRP'</span><br />
<span style="color: blue;">AND</span> <span style="color: maroon;">um_menu_id</span> <span style="color: blue;">IN</span> <span style="color: maroon;">(</span><span style="color: blue;">SELECT</span> <span style="color: maroon;">menu_id</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_menus</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: maroon;">menu_parent_id</span><br />
<span style="color: blue;">START</span> <span style="color: blue;">WITH</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: red;">'101'</span><span style="color: maroon;">)</span><span style="color: maroon;">)</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: maroon;">menu_parent_id</span><br />
<span style="color: blue;">ORDER</span> <span style="color: blue;">SIBLINGS</span> <span style="color: blue;">BY</span> <span style="color: maroon;">menu_id</span><br />
</span></code></p>
<p>And it all came into place. Almost.</p>
<p>Have a look:</p>
<p><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query4.png"><img class="alignnone size-full wp-image-217" title="query4" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query4.png" alt="query4" width="189" height="480" /></a></p>
<p>Unfortunately, it wasn&#8217;t quite right, as  the query was going into an almost infinite loop, as the child record itself became the root record.</p>
<p>I had a look at the query again, and realized that my query itself was wrong, as corrected it to<br />
<code><br />
<span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">SELECT</span> <span style="color: #ff0080;"><strong>Lpad</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: silver;">,</span><span style="color: #ff0080;"><strong>Length</strong></span><span style="color: maroon;">(</span><span style="color: maroon;">menu_scr_name</span><span style="color: maroon;">)</span> <span style="color: silver;">+</span> <span style="color: blue;">LEVEL</span> <span style="color: silver;">*</span> <span style="color: black;">4</span> <span style="color: silver;">-</span> <span style="color: black;">4</span><span style="color: silver;">,</span><span style="color: red;">'-'</span><span style="color: maroon;">)</span> <span style="color: maroon;">"Menu"</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">menu_id</span> <span style="color: blue;">IN</span> <span style="color: maroon;">(</span><span style="color: blue;">SELECT</span> <span style="color: maroon;">um_menu_id</span><br />
<span style="color: blue;">FROM</span> <span style="color: maroon;">menu_user_menus</span><br />
<span style="color: blue;">WHERE</span> <span style="color: maroon;">um_group_id</span> <span style="color: silver;">=</span> <span style="color: red;">'USGRP'</span><span style="color: maroon;">)</span><br />
<span style="color: blue;">CONNECT</span> <span style="color: blue;">BY</span> <span style="color: blue;">NOCYCLE</span> <span style="color: blue;">PRIOR</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: maroon;">menu_parent_id</span><br />
<span style="color: blue;">START</span> <span style="color: blue;">WITH</span> <span style="color: maroon;">menu_id</span> <span style="color: silver;">=</span> <span style="color: red;">'101'</span><br />
<span style="color: blue;">ORDER</span> <span style="color: blue;">SIBLINGS</span> <span style="color: blue;">BY</span> <span style="color: maroon;">menu_seq_no</span><span style="color: silver;">;</span><br />
</span></code></p>
<p>So in essence, I got rid of the unnecessary inner sub-query and voila!</p>
<p><a href="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query5.png"><img class="alignnone size-full wp-image-218" title="query5" src="http://kurast.sathyabh.at/wp-content/uploads/2009/01/query5.png" alt="query5" width="215" height="520" /></a></p>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2008/06/24/query-for-displaying-the-calender-of-the-current-year-using-sql/' rel='bookmark' title='Query For Displaying The Calender of The Current Year using SQL'>Query For Displaying The Calender of The Current Year using SQL</a></li>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
<li><a href='http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/' rel='bookmark' title='Exporting and Importing An Oracle database from one schema/user to Another schema/user easily'>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2009/01/19/the-power-and-simplicity-of-oracle-hierarchical-queries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exporting and Importing An Oracle database from one schema/user to Another schema/user easily</title>
		<link>http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/</link>
		<comments>http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 03:40:25 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[data files]]></category>
		<category><![CDATA[exp]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[imp]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[tablespace]]></category>

		<guid isPermaLink="false">http://sathyabh.at/?p=179</guid>
		<description><![CDATA[Couple of days ago at work I was asked to create a new environment(schema, user) for specific application testing conditions. While that was no big deal, I was also asked to import all the data from existing production environment into a new environment &#8211; and I was in a bit of bother here &#8211; generally [...]
Related posts:<ol>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2008%252F12%252F01%252Fexporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Exporting%20and%20Importing%20An%20Oracle%20database%20from%20one%20schema%2Fuser%20to%20Another%20schema%2Fuser%20easily%22%20%7D);"></div>
<p>Couple of days ago at work I was asked to create a new environment(schema, user) for specific application testing conditions. While that was no big deal, I was also asked to import all the data from existing production environment into a new environment &#8211; and I was in a bit of bother here &#8211; generally the whole importing/exporting is done by DBA&#8217;s not developers. While I knew the usage of exp and imp commands, creating schema would require stuff like tablespace creating, adding data files and more importantly &#8211; grants which I had NO clue on. So after a bit of experimenting and consulting with my fellow colleague Rupam, I finally managed to export and import the data. This post is on how-to go about doing it.</p>
<p>If you want to skip all the commands and all just get the import / export done in 1-click try <a href="http://www.softpedia.com/get/Internet/Servers/Database-Utils/Easy-Dump-Oracle.shtml" target="_blank">Easy Dump Oracle 1.1</a> &#8211; a tool which I found on the database server after all the headbanging <img src='http://sathyabh.at/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> </p>
<p>Anyways here&#8217;s a step by step  process on how you export and import the data &#8211; do note that Easy Dump Oracle can import data ONLY if required grants are given to the user and tablespace has been allocated. For that you need to follow the below mentioned steps.</p>
<p><span id="more-179"></span></p>
<p>First, export the user/schema that you want to import to. For that open the command prompt and type</p>
<blockquote><p><code>exp user/password@hoststring file=filename.dmp log=filename.log</code></p></blockquote>
<p>Next, we&#8217;ll have to create a tablespace and associate that tablespace to a datafile. For that we&#8217;ll need to know the location where the datafiles are stored. If you don&#8217;t know the location of datafiles then find out using the query</p>
<blockquote><p><code>select file_name from dba_data_files;</code></p></blockquote>
<p>Make a note of the location of the data files the above query shows.<br />
Next create a tablespace and associate a datafile. For that, open SQL*Plus prompt and type</p>
<blockquote><p><code>create tablespace &lt;tablespace-name&gt;   datafile '&lt;location-of-datafile-datafile-name&gt;' size &lt;desired-size&gt;;</code></p></blockquote>
<p>The  can be as per your needs. If you aren&#8217;t sure if the size specified here is sufficient add &#8216;autoextend on &#8216; to the above query, else you might end up with a import terminated halfway because of insuffient space allocated.</p>
<p>Next create a user</p>
<blockquote><p><code>Create user &lt;username&gt;  identified by &lt;password&gt;<br />
default tablespace &lt;name-of-tablespace&gt; quota unlimited on &lt;name-of-tablespace&gt; ;</code></p></blockquote>
<p>Next, give the required grants</p>
<blockquote><p><code>grant connect,create session,imp_full_database to &lt;username&gt;;</code></p></blockquote>
<p>Now finally import the data you&#8217;d exported earlier by typing the the below at the command prompt</p>
<blockquote><p><code>imp username/password@hoststring file=filename.dmp log=filename.log full=y</code></p></blockquote>

<p>Related posts:</p><ol>
<li><a href='http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/' rel='bookmark' title='PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle'>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2008/12/01/exporting-and-importing-an-oracle-database-from-one-schemauser-to-another-schemauser-easily/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PL/SQL Procedure To Reset A Sequence To A Predefined Number in Oracle</title>
		<link>http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/</link>
		<comments>http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 18:06:27 +0000</pubDate>
		<dc:creator>sathya</dc:creator>
				<category><![CDATA[Oracle & PL/SQL Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Primary key]]></category>
		<category><![CDATA[reset]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/</guid>
		<description><![CDATA[Over the period of time that I’ve been working on PL/SQL, the one the thing that we end up doing often is reset the sequences we use for Primary keys in our tables. Why do we do that, you might wonder. Consider this case: You enter some values via the front end. Assume that there [...]
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fsathyabh.at%252F2008%252F08%252F11%252Fplsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22PL%2FSQL%20Procedure%20To%20Reset%20A%20Sequence%20To%20A%20Predefined%20Number%20in%20Oracle%22%20%7D);"></div>
<p>Over the period of time that I’ve been working on PL/SQL, the one the thing that we end up doing often is reset the sequences we use for Primary keys in our tables. Why do we do that, you might wonder.</p>
<p>Consider this case:</p>
<p><span id="more-106"></span></p>
<p>You enter some values via the front end. Assume that there are *a lot* of fields to be entered. You save them. The &lt;sequence-name&gt;.nextval will pick up the next number in the sequence and goes into your table as the primary key. Now consider that most of the data is common, so instead of entering them via the front-end, you fire up Toad or SQL Developer or PL/SQL Developer and make use of the &#8220;duplicate row” feature. You enter some random value in the PK column, and save it.</p>
<p>Now later on while working on the application, it may happen that the sequence will generate a number which you’d already entered. Now while trying to save this, you’ll end an Oracle error: ORA-00001: Unique Constraint Violated since the sequence number you’re trying to enter is already present, hence violating the constraints.</p>
<p>So here’s a small PL/SQL procedure to reset the sequence to a predefined number. Note that I’m not dropping the sequence or initialising it to zero, that defeats the purpose as I mentioned above</p>
<p>CREATE OR REPLACE PROCEDURE Set_seq_To<br />
(p_Name  IN VARCHAR2,<br />
p_val   IN NUMBER)<br />
IS<br />
v_num  NUMBER;<br />
BEGIN<br />
EXECUTE IMMEDIATE &#8216;SELECT &#8216;<br />
||p_Name<br />
||&#8217;.NEXTVAL FROM DUAL&#8217; INTO v_num;<br />
EXECUTE IMMEDIATE &#8216;ALTER SEQUENCE &#8216;<br />
||p_Name<br />
||&#8217; INCREMENT BY &#8216;<br />
||(p_val &#8211; v_num &#8211; 1)<br />
||&#8217; MINVALUE 1&#8242;;<br />
EXECUTE IMMEDIATE &#8216;SELECT &#8216;<br />
||p_Name<br />
||&#8217;.NEXTVAL FROM DUAL&#8217; INTO v_num;<br />
EXECUTE IMMEDIATE &#8216;ALTER SEQUENCE &#8216;<br />
||p_Name<br />
||&#8217; INCREMENT BY 1 &#8216;;<br />
dbms_Output.Put_Line(&#8216;Sequence &#8216;<br />
||p_Name<br />
||&#8217; IS NOW AT &#8216;<br />
||p_val);<br />
END;</p>
<p>p_Name is the name of the sequence, and p_val is the number you want to set it to. I’d say the best number to pass to p_val is to take the Max val of your primary key column. Hope this might help you out.</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:38d978ff-52f9-4c1b-8bcf-16465f885f88" class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Oracle">Oracle</a>,<a rel="tag" href="http://technorati.com/tags/PL%2fSQL">PL/SQL</a>,<a rel="tag" href="http://technorati.com/tags/PLSQL">PLSQL</a>,<a rel="tag" href="http://technorati.com/tags/SQL">SQL</a>,<a rel="tag" href="http://technorati.com/tags/sequence">sequence</a>,<a rel="tag" href="http://technorati.com/tags/Primary+key">Primary key</a>,<a rel="tag" href="http://technorati.com/tags/reset">reset</a>,<a rel="tag" href="http://technorati.com/tags/sathya">sathya</a>,<a rel="tag" href="http://technorati.com/tags/My+World">My World</a>,<a rel="tag" href="http://technorati.com/tags/sathyabh.at">sathyabh.at</a></div>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sathyabh.at/2008/08/11/plsql-procedure-to-reset-a-sequence-to-a-predefined-number-in-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

