<?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"
	>

<channel>
	<title>Laurent Schneider</title>
	<atom:link href="http://laurentschneider.com/rss2" rel="self" type="application/rss+xml" />
	<link>http://laurentschneider.com</link>
	<description>Oracle Certified Master</description>
	<pubDate>Wed, 25 Aug 2010 13:30:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>last access time of a file</title>
		<link>http://laurentschneider.com/wordpress/2010/08/last-access-time-of-a-file.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/08/last-access-time-of-a-file.html#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:30:19 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[Solaris]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[stat]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=724</guid>
		<description><![CDATA[I was reading http://blogs.oracle.com/myoraclediary and there was a command about printing the modification details of a file.
In Linux / Cygwin &#8220;stat&#8221; exists as a command 
$ stat /etc/hosts
Access: 2010-08-25 15:20:49.782522200 +0200
Modify: 2010-08-18 14:04:25.868114200 +0200
Change: 2010-08-18 14:04:26.072413100 +0200
Or use the one-liner perl below

### st_atime;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; /* Time of last access */
$ perl -e &#039;use POSIX;[-f&#34;/etc/hosts&#34;]&#38;&#38;print ctime((stat(_))[8])&#039;
Wed Aug [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading <a href="http://blogs.oracle.com/myoraclediary/2010/08/useful_unix_commands_for_dbas.html">http://blogs.oracle.com/myoraclediary</a> and there was a command about printing the modification details of a file.</p>
<p>In Linux / Cygwin &#8220;stat&#8221; exists as a command </p>
<p><pre><code>$ stat /etc/hosts
Access: 2010-08-25 15:20:49.782522200 +0200
Modify: 2010-08-18 14:04:25.868114200 +0200
Change: 2010-08-18 14:04:26.072413100 +0200</code></pre></p>
<p>Or use the one-liner perl below<br />
<pre><code>
### st_atime;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Time of last access */
$ perl -e &#039;use POSIX;[-f&quot;/etc/hosts&quot;]&amp;&amp;print ctime((stat(_))[8])&#039;
Wed Aug 25 15:20:08 2010
### st_mtime;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Time of last data modification */
$ perl -e &#039;use POSIX;[-f&quot;/etc/hosts&quot;]&amp;&amp;print ctime((stat(_))[9])&#039;
Wed Jun 10 11:36:40 2009
### st_ctime;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Time of last file status change */
$ perl -e &#039;use POSIX;[-f&quot;/etc/hosts&quot;]&amp;&amp;print ctime((stat(_))[10])&#039; 
Wed Aug 25 01:00:07 2010
</code></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/08/last-access-time-of-a-file.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>OCE Solaris Network Admin</title>
		<link>http://laurentschneider.com/wordpress/2010/08/oce-solaris-network-admin.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/08/oce-solaris-network-admin.html#comments</comments>
		<pubDate>Wed, 25 Aug 2010 10:10:16 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[Solaris]]></category>

		<category><![CDATA[certification]]></category>

		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=718</guid>
		<description><![CDATA[I read Paul Sorensen blog : Sun certifications will be renamed next week.
For instance the Sun Certified Network Administrator will be Oracle Certified Expert, Oracle Solaris 10 Network Administrator. 
But to get the OCE Solaris title, you need to upgrade your certification [...] to receive an Oracle certification title (check more details on the Oracle [...]]]></description>
			<content:encoded><![CDATA[<p>I read <a href="http://blogs.oracle.com/certification/2010/08/0328.html">Paul Sorensen</a> blog : Sun certifications will be renamed next week.</p>
<p>For instance the <i>Sun Certified Network Administrator</i> will be <i>Oracle Certified Expert, Oracle Solaris 10 Network Administrator</i>. </p>
<p>But to get the OCE Solaris title, you need to <i>upgrade your certification [...] to receive an Oracle certification title</i> (check more details on the Oracle Certification website <a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=433">here</a>). </p>
<p>I never upgraded my Sun credentials, I am a Solaris 2.6 system admin and Solaris 7 network admin, but this equivalency with OCE surprised me.</p>
<p>There are even two OCM Java certifications : Oracle Certified Master, Java EE 5 Enterprise Architect, originally <a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=326">Sun Certified Enterprise Architect (SCEA)</a> and Oracle Certified Master, Java SE6 Developer, originally <a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=321">Sun Certified Java Developer (SCJD)</a></p>
<p>Also, since a few months, there is an upgrade to the 9i OCM DBA certification : <a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=41&#038;p_org_id=&#038;lang=&#038;p_exam_id=11gOCMU">11g OCM Upgrade</a>. I hope I can do this one <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/08/oce-solaris-network-admin.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Do you know the ORA- nonerrors?</title>
		<link>http://laurentschneider.com/wordpress/2010/08/do-you-know-the-ora-nonerrors.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/08/do-you-know-the-ora-nonerrors.html#comments</comments>
		<pubDate>Tue, 17 Aug 2010 16:02:52 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[sql]]></category>

		<category><![CDATA[sqlplus]]></category>

		<category><![CDATA[ORA-28002]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=716</guid>
		<description><![CDATA[In one of my script, I am checking at the end for any ORA- error. And if I have any ORA- error, I quit with an error. 
So far so good.
Also when I run a report from the shell, I do set the sqlplus settings I like and I expect the script to receive the [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my script, I am checking at the end for any ORA- error. And if I have any ORA- error, I quit with an error. </p>
<p>So far so good.</p>
<p>Also when I run a report from the shell, I do set <a href="http://laurentschneider.com/wordpress/2005/12/the-sqlplus-settings-i-like.html">the sqlplus settings I like</a> and I expect the script to receive the output with no ORA- error at the beginning.</p>
<p>But watch this !</p>
<p><pre><code>$ echo &quot;set feed off hea off newp none
conn scott/tiger
select * from dual;&quot;|sqlplus /nolog
ERROR:
ORA-28002: the password will expire within 10 days

X</code></pre></p>
<p>My password will expire in 10 days. And this screw up my day <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/08/do-you-know-the-ora-nonerrors.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hardcoding SYSDATE</title>
		<link>http://laurentschneider.com/wordpress/2010/08/hardcoding-sysdate.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/08/hardcoding-sysdate.html#comments</comments>
		<pubDate>Mon, 16 Aug 2010 14:52:31 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[plsql]]></category>

		<category><![CDATA[sql]]></category>

		<category><![CDATA[sysdate]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=714</guid>
		<description><![CDATA[I see TRUNC(SYSDATE) in the code very often. Is this good or bad?
Over my past two years as a developer, I can tell you it is pretty bad. What does TRUNC(SYSDATE) mean? It is today&#8217;s date. 
But when does today starts and ends? And at the time of the writing, it is already tomorrow in [...]]]></description>
			<content:encoded><![CDATA[<p>I see TRUNC(SYSDATE) in the code very often. Is this good or bad?</p>
<p>Over my past two years as a developer, I can tell you it is pretty bad. What does TRUNC(SYSDATE) mean? It is today&#8217;s date. </p>
<p>But when does today starts and ends? And at the time of the writing, it is already tomorrow in Thailand. </p>
<p>We could argue about using CURRENT_DATE instead of sysdate, but it does not solve everything. Maybe you want your day to end at 10:30pm and initialize for the next day after some post processing. Maybe you want some components running in different timezones. Maybe you want to rollback and rollforward the date in your test systems&#8230;</p>
<p>Also the bad news, if your report hardcodes SYSDATE, kind of <code>SELECT SUM(AMT) FROM T WHERE EXPIRY_DATE&gt;TRUNC(SYSDATE)</code>, you will not be able to run it tomorrow in case it fails today.</p>
<p>No, I think that you would better store the date in a table and update it daily. </p>
<p>So you will have <code>SELECT SUM(T.AMT) FROM T, TRADINGDAY WHERE T.EXPIRY_DATE&gt;TRADINGDAY.TRADINGDAY</code> and a daily job running <code>UPDATE TRADEDAY SET TRADINGDAY=TRADINGDAY+1;</code>. </p>
<p>You may want to consider the performance overhead of reading from a table instead of using the very performant SYSDATE function&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/08/hardcoding-sysdate.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>On Express Edition</title>
		<link>http://laurentschneider.com/wordpress/2010/08/on-express-edition.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/08/on-express-edition.html#comments</comments>
		<pubDate>Mon, 16 Aug 2010 14:08:52 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[Solaris]]></category>

		<category><![CDATA[license]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[express edition]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=710</guid>
		<description><![CDATA[If you want to start with developing free software on old technology, you can download the Oracle Database 10g Express Edition.
Actually, Oracle 10g is more than 5 years old and it is the only version available as Express Edition, 11g has not been released at the time of the writing, and no patch has been [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to start with developing free software on old technology, you can download the <a href="http://www.oracle.com/technetwork/database/express-edition/downloads/index.html">Oracle Database 10g Express Edition</a>.</p>
<p>Actually, Oracle 10g is more than 5 years old and it is the only version available as Express Edition, 11g has not been released at the time of the writing, and no patch has been released, not even for the worst bugs or security breaches.</p>
<p>Most probably you will not want to run this for your sensitive data. </p>
<p>If you are serious about Oracle Development, you could download the <a href="http://www.oracle.com/technology/database">Enterprise Edition</a> for free, and get the <a href="https://shop.oracle.com">Personal Edition on Oracle Shop</a> for support and patches.</p>
<p>Last Friday 13th August, a <a href="http://opensolaris.org/jive/thread.jspa?messageID=496203&#038;tstart=0/">news/rumor</a> (not an official announcement) was posted on the opensolaris forum, apparently OpenSolaris has been cancelled in favor of an Oracle Solaris 11 Express. Not sure if it will come in the same format as the database XE, but this does not sound to please the community.</p>
<p>After the <a href="http://www.google.com/search?q=Oracle+sues+Google">Oracle sues Google</a>, it does not make Oracle very popular in the opensource community at the very moment</p>
<p>YMMV </p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/08/on-express-edition.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>to cvs or to subversion</title>
		<link>http://laurentschneider.com/wordpress/2010/07/to-cvs-or-to-subversion.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/07/to-cvs-or-to-subversion.html#comments</comments>
		<pubDate>Wed, 14 Jul 2010 11:39:09 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[unix]]></category>

		<category><![CDATA[cvs]]></category>

		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=702</guid>
		<description><![CDATA[First surprise, after migration, the size of my subversion folder is double the size of my cvs folder. With a bunch of 2Gb disks shared amoung dozens of unix persons, and regular reminders the current usage reached 100%, you will feel the pain of having each developers doublesizing its home directory&#8230;
The reason is a .svn/test-base [...]]]></description>
			<content:encoded><![CDATA[<p>First surprise, after migration, the size of my subversion folder is double the size of my cvs folder. With a bunch of 2Gb disks shared amoung dozens of unix persons, and regular reminders the current usage reached 100%, you will feel the pain of having each developers doublesizing its home directory&#8230;<br />
The reason is a .svn/test-base directory containing a duplicate of your local copy.<br />
The benefit there is that it reduces network usage, for instance when diffing with the working version.</p>
<p>Second surprise, not sure if it is a generic issue or related to the one above, a full checkout take ages <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<p>svn and cvs command line interfaces almost have the same options, a bit like vi and vim -vi is my favorite- but the &#8220;tagging&#8221; massively differs. The is no <i>cvs tag</i> command in subversion, you use a different syntax.<br />
cvs :<br />
<pre><code>
$ cd /home/lsc/CVS/proj1/source/pkg
$ cvs tag MYTAG helloworld.pkb helloworld.pks
</code></pre><br />
now enjoy the power of subversion! [updated as I found the --parents option]<br />
<pre><code>
$ cd /home/lsc/SVN/proj1/source/pkg
$ svn copy --parents helloworld.pkb http://myserver.domain.com/svn/REPOS1/proj1/tags/MYTAG/proj1/source/pkg -m &quot;my first svn tag&quot;
$ svn copy --parents helloworld.pks http://myserver.domain.com/svn/REPOS1/proj1/tags/MYTAG/proj1/source/pkg -m &quot;my first svn tag&quot;
</code></pre></p>
<p>I always loved the cvs rename command<br />
<pre><code>$ cvs rename pkg1.pkb pkg2.pkb
cvs [rename aborted]: Remote server does not support rename
</code></pre><br />
Joke apart, in CVS I used to physically logon to the server and manually move the pkg1.pkb,v to pkg2.pkb,v<br />
Renaming works in subversion :<br />
<pre><code>
$ svn move pkg1.pkb pkg2.pkb
A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pkg2.pkb
D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pkg1.pkb
</code></pre></p>
<p><font color="red">Update:</font> One more annoyance, you cannot checkout a single file <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
<a href="http://subversion.apache.org/faq.html#single-file-checkout">subversion faq</a></p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/07/to-cvs-or-to-subversion.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>extract xml from the command line</title>
		<link>http://laurentschneider.com/wordpress/2010/06/extract-xml-from-the-command-line.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/06/extract-xml-from-the-command-line.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 12:33:17 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[unix]]></category>

		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=694</guid>
		<description><![CDATA[I just discovered this morning this cool utility in my /bin directory : xmllint
You can use it to extract values from your xml files within your shell scripts

$ cat foo.xml
&#60;emplist&#62;
&#160;&#160;&#60;emp no=&#34;1&#34;&#62;
&#160;&#160;&#160;&#160;&#60;ename&#62;John&#60;/ename&#62;
&#160;&#160;&#60;/emp&#62;
&#160;&#160;&#60;emp no=&#34;2&#34;&#62;
&#160;&#160;&#160;&#160;&#60;ename&#62;Jack&#60;/ename&#62;
&#160;&#160;&#60;/emp&#62;
&#60;/emplist&#62;
$ echo &#039;cat //emplist/emp[@no=&#34;1&#34;]/ename/text()&#039;&#124;
&#160;&#160;xmllint --shell foo.xml &#124;
&#160;&#160;sed -n 3p
John
I like this !
]]></description>
			<content:encoded><![CDATA[<p>I just discovered this morning this cool utility in my /bin directory : xmllint</p>
<p>You can use it to extract values from your xml files within your shell scripts</p>
<p><pre><code>
$ cat foo.xml
&lt;emplist&gt;
&nbsp;&nbsp;&lt;emp no=&quot;1&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ename&gt;John&lt;/ename&gt;
&nbsp;&nbsp;&lt;/emp&gt;
&nbsp;&nbsp;&lt;emp no=&quot;2&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ename&gt;Jack&lt;/ename&gt;
&nbsp;&nbsp;&lt;/emp&gt;
&lt;/emplist&gt;
$ echo &#039;cat //emplist/emp[@no=&quot;1&quot;]/ename/text()&#039;|
&nbsp;&nbsp;xmllint --shell foo.xml |
&nbsp;&nbsp;sed -n 3p
John</code></pre></p>
<p>I like this !</p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/06/extract-xml-from-the-command-line.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>connect by and recursive with (part 2)</title>
		<link>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-with-part-2.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-with-part-2.html#comments</comments>
		<pubDate>Thu, 20 May 2010 09:11:47 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[11gR2]]></category>

		<category><![CDATA[sql]]></category>

		<category><![CDATA[recursive with]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=688</guid>
		<description><![CDATA[According to the doc
The subquery_factoring_clause now supports recursive subquery
factoring (recursive WITH), which lets you query hierarchical data.
This feature is more powerful than CONNECT BY in that it
provides depth-first search and breadth-first search, and supports
multiple recursive branches. A new search_clause and cycle_clause
let you specify an ordering for the rows and mark cycles in the
recursion
As written there [...]]]></description>
			<content:encoded><![CDATA[<p>According to <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/wnsql.htm" target="_new">the doc</a><br />
<i>The subquery_factoring_clause now supports recursive subquery<br />
factoring (recursive WITH), which lets you query hierarchical data.<br />
This feature is <b>more powerful</b> than CONNECT BY in that it<br />
provides depth-first search and breadth-first search, and supports<br />
multiple recursive branches. A new search_clause and cycle_clause<br />
let you specify an ordering for the rows and mark cycles in the<br />
recursion</i></p>
<p>As written <a href="http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-cte.html">there</a> and <a href="http://laurentschneider.com/wordpress/2010/05/number-series.html">there</a>, <i>recursive with</i> has more capabilities. It is also ANSI and implemented in DB2, MS SQL Server. CONNECT BY is an Oracle oddity. But does <i>recursive with</i> perfoms as well as <i>connect by</i>?</p>
<ol>
<li>Create a big emp</li>
<p><pre><code>
create table big_emp as
with t(empno,mgr) as
(select 1, null from dual
union all 
select empno+1,trunc(dbms_random.value(1+empno/10,empno))
from t 
where empno&lt;100000)
select * from t
</code></pre></p>
<li>execution plan</li>
<p><strong>CONNECT BY</strong><br />
<pre><code>
select empno,mgr
from big_emp
connect by mgr = prior empno
start with mgr is null;

E M 
- -
1 -&nbsp;&nbsp;
2 1 
4 2 
6 2 
8 6 

Operation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object&nbsp;&nbsp;&nbsp;&nbsp;Rows Time Cost&nbsp;&nbsp; Bytes
------------------------- ------- ------ ---- ---- -------
SELECT STATEMENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;185&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78
CONNECT BY WITH FILTERING
TABLE ACCESS FULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BIG_EMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp; 61&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10
HASH JOIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;46
CONNECT BY PUMP
TABLE ACCESS FULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BIG_EMP 100000&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp; 61 1000000
</code></pre></p>
<p><strong>recursive WITH</strong><br />
<pre><code>
with e(empno,mgr) as (
select empno, mgr 
from big_emp 
where mgr is null
union all
select f.empno,f.mgr 
from big_emp f, e 
where e.empno=f.mgr)
select empno,mgr
from e;

E M
- -
1 -&nbsp;&nbsp;
2 1 
3 1 
4 2 
5 3 
...

Operation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object&nbsp;&nbsp;&nbsp;&nbsp;Rows Time Cost&nbsp;&nbsp; Bytes
------------------------- ------- ------ ---- ---- -------
SELECT STATEMENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;183&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78
VIEW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;183&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78
UNION ALL (RECURSIVE WITH) BREADTH FIRST
TABLE ACCESS FULL BIG_EMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp; 61&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10
HASH JOIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;46
RECURSIVE WITH PUMP
TABLE ACCESS FULL BIG_EMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100000&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp; 61 1000000
</code></pre></p>
<p>In this particular simple case, it seems CONNECT BY have a 1% higher cost.</p>
<li>execution time</li>
<p><strong>CONNECT BY</strong><br />
<pre><code>
select sum(mgr)
from 
(
select empno,mgr
from big_emp
connect by mgr = prior empno
start with mgr is null
)

SUM(MGR) 
------------
2745293877 

1 rows returned in 0.73 seconds 
</code></pre></p>
<p><strong>recursive with</strong><br />
<pre><code>
with e(empno,mgr) as (
select empno, mgr 
from big_emp 
where mgr is null
union all
select f.empno,f.mgr 
from big_emp f, e 
where e.empno=f.mgr)
select sum(mgr)
from e;

SUM(MGR) 
------------
2745293877 

1 rows returned in 1.24 seconds 
</code></pre>
</ol>
<p>Honestly I am not surprised that CONNECT BY is faster, CONNECT BY has been in the Oracle database forever and has been massively tuned in 8.1.7.4.</p>
<p>And then one day you find, ten years have got behind you.</p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-with-part-2.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>CONNECT BY and Recursive CTE</title>
		<link>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-cte.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-cte.html#comments</comments>
		<pubDate>Wed, 19 May 2010 15:41:27 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[11gR2]]></category>

		<category><![CDATA[sql]]></category>

		<category><![CDATA[recursive subquery factoring]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=683</guid>
		<description><![CDATA[11gR2 introduced a new mechanism to build up hierarchies.
I remembered a thread in developpez.net that reveals the dubious implementation of nocycle in 10g.
For the CONNECT BY ISLEAF, I have read the technique on amis.nl.
Ok, here is my graph

The 10g query

with o as
(
SELECT &#039;A&#039; obj, &#039;B&#039; link from dual union all
SELECT &#039;A&#039;, &#039;C&#039; from dual union [...]]]></description>
			<content:encoded><![CDATA[<p>11gR2 introduced a new mechanism to build up hierarchies.</p>
<p>I remembered <a href="http://www.developpez.net/forums/d742374/bases-donnees/oracle/sql/10g-bug-connect-by-nocycle-requete-hierarchique/">a thread in developpez.net</a> that reveals the dubious implementation of nocycle in 10g.</p>
<p>For the CONNECT BY ISLEAF, I have read the technique on <a href="http://technology.amis.nl/blog/6533/oracle-11gr2-alternative-for-connect_by_isleaf-function-for-recursive-subquery-factoring-dedicated-to-anton">amis.nl</a>.</p>
<p>Ok, here is my graph<br />
<img src="http://laurentschneider.com/wordpress/wp-content/uploads/2010/05/abcde.png" title="abcde" class="alignnone size-full wp-image-684" /></p>
<p>The 10g query<br />
<pre><code>
with o as
(
SELECT &#039;A&#039; obj, &#039;B&#039; link from dual union all
SELECT &#039;A&#039;, &#039;C&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;C&#039;, &#039;D&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;D&#039;, &#039;C&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;D&#039;, &#039;E&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;E&#039;, &#039;E&#039; from dual)
select connect_by_root obj root,level,obj,link,
&nbsp;&nbsp;sys_connect_by_path(obj||
&#039;-&gt;&#039;
||link,&#039;,&#039;),
&nbsp;&nbsp;connect_by_iscycle,
&nbsp;&nbsp;connect_by_isleaf
from o 
connect by nocycle obj=prior link
start with obj=&#039;A&#039;;

ROOT LEVEL O L PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CYCLE&nbsp;&nbsp;LEAF
---- ----- - - -------------------- ----- -----
A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 A B ,A-&gt;B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 1
A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 A C ,A-&gt;C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 C D ,A-&gt;C,C-&gt;D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 D E ,A-&gt;C,C-&gt;D,D-&gt;E&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp; 1
</code></pre></p>
<p>Obviously in 10g the connect by nocycle does works well with that kind of graphs, D-C and E-E are missing and C-D and D-E are marked as cycling&#8230;</p>
<p>Let&#8217;s try the 11gR2 equivalency.<br />
<pre><code>
with o(obj,link) as
(
SELECT &#039;A&#039;, &#039;B&#039; from dual union all
SELECT &#039;A&#039;, &#039;C&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;C&#039;, &#039;D&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;D&#039;, &#039;C&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;D&#039;, &#039;E&#039; from dual union all
SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;E&#039;, &#039;E&#039; from dual),
t(root,lev,obj,link,path) as (
select obj,1,obj,link,cast(obj||&#039;-&gt;&#039;||link 
as varchar2(4000))
from o 
where obj=&#039;A&#039;&nbsp;&nbsp;-- START WITH
union all
select 
&nbsp;&nbsp;t.root,t.lev+1,o.obj,o.link,
&nbsp;&nbsp;t.path||&#039;, &#039;||o.obj||
&nbsp;&nbsp;&nbsp;&nbsp;&#039;-&gt;&#039;
&nbsp;&nbsp;&nbsp;&nbsp;||o.link
from t, o 
where t.link=o.obj
)
search depth first by obj set ord
cycle obj set cycle to 1 default 0
select root,lev,obj,link,path,cycle,
&nbsp;&nbsp;&nbsp;&nbsp;case
&nbsp;&nbsp;&nbsp;&nbsp;when (lev - lead(lev) over (order by ord)) &lt; 0
&nbsp;&nbsp;&nbsp;&nbsp;then 0
&nbsp;&nbsp;&nbsp;&nbsp;else 1
&nbsp;&nbsp;&nbsp;&nbsp;end is_leaf
 from t;

ROOT LEV&nbsp;&nbsp;OBJ&nbsp;&nbsp;LINK PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CYCLE IS_LEAF
---- ---- ---- ---- --------------------------- ----- -------
A&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;&nbsp;&nbsp;&nbsp;B&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
A&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D, D-&gt;C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D, D-&gt;C, C-&gt;D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
A&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D, D-&gt;E&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D, D-&gt;E, E-&gt;E&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0
A&nbsp;&nbsp;&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;A-&gt;C, C-&gt;D, D-&gt;E, E-&gt;E, E-&gt;E&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
</code></pre></p>
<p>It looks good <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you exclude the rows with cycle=1, you get the six rows for the graph.</p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/05/connect-by-and-recursive-cte.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>read without Enter</title>
		<link>http://laurentschneider.com/wordpress/2010/05/read-without-enter.html</link>
		<comments>http://laurentschneider.com/wordpress/2010/05/read-without-enter.html#comments</comments>
		<pubDate>Tue, 18 May 2010 10:36:41 +0000</pubDate>
		<dc:creator>Laurent Schneider</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[unix]]></category>

		<category><![CDATA[read]]></category>

		<guid isPermaLink="false">http://laurentschneider.com/?p=681</guid>
		<description><![CDATA[A small unix tip today.
Do you want to continue ?
If you are expecting &#8220;y&#8221; or &#8220;n&#8221; but do not want to enforce the user to type y[Enter] but simply y, you can use the -n option in bash.
Within a ksh script:

yorn=$(bash -c &#039;read -p &#34;Do you want to continue ? &#34; -n 1 ans;echo &#34;$ans&#34;&#039;)

Within [...]]]></description>
			<content:encoded><![CDATA[<p>A small unix tip today.</p>
<p>Do you want to continue ?</p>
<p>If you are expecting &#8220;y&#8221; or &#8220;n&#8221; but do not want to enforce the user to type <b><i>y[Enter]</i></b> but simply <b><i>y</i></b>, you can use the -n option in bash.</p>
<p>Within a ksh script:<br />
<pre><code>
yorn=$(bash -c &#039;read -p &quot;Do you want to continue ? &quot; -n 1 ans;echo &quot;$ans&quot;&#039;)
</code></pre></p>
<p>Within bash:<br />
<pre><code>
read -n 1 yorn
</code></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://laurentschneider.com/wordpress/2010/05/read-without-enter.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
