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

<channel>
	<title>Featheast Lee 李羽东</title>
	<atom:link href="http://www.featheast.com/en/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.featheast.com/en/wordpress</link>
	<description>Life in Melbourne, Tech in Software, and Travel around the world</description>
	<pubDate>Thu, 12 Jan 2012 02:36:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cache in AppEngine</title>
		<link>http://www.featheast.com/en/wordpress/google-app-engine/cache-in-appengine</link>
		<comments>http://www.featheast.com/en/wordpress/google-app-engine/cache-in-appengine#comments</comments>
		<pubDate>Tue, 10 Jan 2012 07:28:34 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Google App Engine]]></category>

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

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

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

		<category><![CDATA[cache-control]]></category>

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

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=127</guid>
		<description><![CDATA[To correctly set the cache for Google App Engine looks like an easy task, but in order to fully understand the story behind the scene turns out to be a little bit tricky as there are some hidden points that only can be discovered from various posts that scattered in the cloud.
Some highlighted points here [...]]]></description>
			<content:encoded><![CDATA[<p>To correctly set the cache for Google App Engine looks like an easy task, but in order to fully understand the story behind the scene turns out to be a little bit tricky as there are some hidden points that only can be discovered from various posts that scattered in the cloud.</p>
<p>Some highlighted points here which I have learned from the research:</p>
<p>1) For static files, the cache is being set in the appengine-web.xml file, you can specify how long it is going to expire within the file.<br />
The cache here is if you don&#8217;t declare your static file here, then quite possibly you will not be able to render your static file well. Google use a different source to serve static files, as a result you have to explicitly tells AppEngine that &#8220;these are the types of static files I am using, and you need to serve it&#8221;. An alternative is to add those static files into your web.xml as a servlet or a filter, which will then be caught by the servlet/filter chain, however, this is not the recommended way to go.</p>
<p>2) You can use a filter to add &#8220;cache-control&#8221; header to static files request/response, but Google will not honor it. To be precisely, Google will always return a private cache-control for your static files regardless what kind of setting you provided. Hence these static files will only available in your private cache pool (local browser), and will expire after your specified length.</p>
<p>3) However, we can use above mentioned method to add &#8220;cache-control&#8221; header to dynamic generated pages, such as jsp file. This is particularly useful for files that rarely change, such as front-page or some introduction pages. And this time, Google will honor your setting in your cache-control header with the right expire time.</p>
<p>4) The way current browser working is a little bit weird but understandable:<br />
If you click a link on a page, then browser will always first check if there is a local cache available, if not then goes to the server to fetch.<br />
If you press F5/Refresh the page, the the browser will just ignore your local browser cache at all, but goes directly to the server. This time, it will use the &#8220;is-modified-since&#8221; header to compare whether the content on the server side is still valid, if it is, then a 304 will return and you will still use your local cache, otherwise a new version will be retrieved.</p>
<p>In short, if you click the link, then it is possible that client will not talk to the server at all, but if you refresh, then the client will always talk to the server.</p>
<p>5) Both Chrome and Firefox have good tools for debugging HTTP Request, see how the cache is working and diagnose each of the specific request.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/google-app-engine/cache-in-appengine/feed</wfw:commentRss>
		</item>
		<item>
		<title>CloudFront Streaming Exception: NetStream.Play.StreamNotFound</title>
		<link>http://www.featheast.com/en/wordpress/cloudfront/cloudfront-streaming-streamnotfound</link>
		<comments>http://www.featheast.com/en/wordpress/cloudfront/cloudfront-streaming-streamnotfound#comments</comments>
		<pubDate>Thu, 29 Dec 2011 23:59:05 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[CloudFront]]></category>

		<category><![CDATA[NetStream.Play.StreamNotFound]]></category>

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

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=121</guid>
		<description><![CDATA[While I am doing some work with CloudFront streaming using S3 bucket as origin, I get some weird exception &#8220;NetStream.Play.StreamNotFound&#8221; randomly. It doesn&#8217;t happen on all files, but just some certain files. Initially, I thought there is something wrong with my encoding configuration which leads to some inconsistency between bitrate to result a failure of [...]]]></description>
			<content:encoded><![CDATA[<p>While I am doing some work with CloudFront streaming using S3 bucket as origin, I get some weird exception &#8220;NetStream.Play.StreamNotFound&#8221; randomly. It doesn&#8217;t happen on all files, but just some certain files. Initially, I thought there is something wrong with my encoding configuration which leads to some inconsistency between bitrate to result a failure of stream rendering, but even I tried out with some of the most popular service online, it still doesn&#8217;t work. And it is only applied to streaming protocols, for normal HTTP protocol it is still working perfectly.</p>
<p>After struggling with it more than one day, I eventually found out the culprit of this failure is because of the file extension.</p>
<p>The rule is: you can not make the file extension in CAPITAL/UPPERCASE/BIG case, otherwise CloudFront won&#8217;t recognize those files thus failed to streaming it.</p>
<p>So, if you want to play with CloudFront streaming, make sure that your file is not xxx.FLV or xxx.MP4, but please name it xxx.flv or xxx.mp4.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/cloudfront/cloudfront-streaming-streamnotfound/feed</wfw:commentRss>
		</item>
		<item>
		<title>Change VM Allocation for Intellij Idea</title>
		<link>http://www.featheast.com/en/wordpress/intellij-idea/change-vm-allocation-for-intellij-idea</link>
		<comments>http://www.featheast.com/en/wordpress/intellij-idea/change-vm-allocation-for-intellij-idea#comments</comments>
		<pubDate>Mon, 28 Nov 2011 22:27:59 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Intellij Idea]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=117</guid>
		<description><![CDATA[This method is suitable for at least the current version I&#8217;m using: 10.5.2, not sure about earlier version but should have no problem in Idea 9. I have also tried on the EAP of 11 without any issues.
Basically, what you need to do is modify the memory configurations in the file:
{IDEA_HOME}/bin/idea.vmoptions
Change the the value to [...]]]></description>
			<content:encoded><![CDATA[<p>This method is suitable for at least the current version I&#8217;m using: 10.5.2, not sure about earlier version but should have no problem in Idea 9. I have also tried on the EAP of 11 without any issues.</p>
<p>Basically, what you need to do is modify the memory configurations in the file:</p>
<p>{IDEA_HOME}/bin/idea.vmoptions</p>
<p>Change the the value to the size you wish to have. In my case, I update the -Xmx to 1536M and -XX:MaxPermSize=500M, which speed up the process and responsiveness of Idea quite a bit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/intellij-idea/change-vm-allocation-for-intellij-idea/feed</wfw:commentRss>
		</item>
		<item>
		<title>Session Clean in Google App Engine</title>
		<link>http://www.featheast.com/en/wordpress/google-app-engine/session-clean-in-google-app-engine</link>
		<comments>http://www.featheast.com/en/wordpress/google-app-engine/session-clean-in-google-app-engine#comments</comments>
		<pubDate>Fri, 30 Sep 2011 06:33:18 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Google App Engine]]></category>

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

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

		<category><![CDATA[GAE/J]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=114</guid>
		<description><![CDATA[It is always sad that with such a good product, the documents always lacking behind, sometimes even years. While a lot of information can be retrieved by using its mother Google, still a formal doc and some practical hint will definitely be helpful than those articles scattered in the sea.
Anyway, to clean the session in [...]]]></description>
			<content:encoded><![CDATA[<p>It is always sad that with such a good product, the documents always lacking behind, sometimes even years. While a lot of information can be retrieved by using its mother Google, still a formal doc and some practical hint will definitely be helpful than those articles scattered in the sea.</p>
<p>Anyway, to clean the session in the AppEngine database is a basic requirement for any real product running on it. If you don&#8217;t clean it, unless you are not using session anywhere, there is definitely one day your datastore will blow out.</p>
<p>Once you have a session hanging around, you will easily detect them under the Datastore Viewer. It is actually a table called _ah_session. (Yep, whenever you see _ah, it means Google is playing some magic background stuff). It will list all current sessions in the app and its expire date as well as the size of it (well, actually it&#8217;s the value, but most of the time, the value is not easy to be displaying there)</p>
<p>Apparently, the most direct way and easiest way is using your hand, tick all those boxes before the sessions, and click the DELETE button, and then yep, all sessions just cleared. Easy right, what if you have 100 sessions? Some one may argue that, you can append &amp;limit=SOME_MAGIC_MAXIMUM_NUMBER_TO_BE_DISPLAYED at the end of the link in the browser, refresh the page, and then clear them all at once. But as far as I know, the maximum number you can set is 200, which means if there are 1000 entries, then you have to go through all 5 pages.</p>
<p>This manual process sounds boring and lack of the self satisfactory as a software developer, don&#8217;t you think? As a programmer, we always look down those guys who has to use mouse and keyboard instead of using their mind to delete stuff. All right, so Google does provides a way to clean the session, it is a servlet, part of the Google Code infrastructure (Being aware of Google&#8217;s BigTable). Basically what you need to do is declare the servlet: SessionCleanupServlet in your web.xml, and get a cron job to call it periodically based on your traffic.</p>
<p><a href="http://radomirml.com/2011/03/26/cleaning-up-expired-sessions-from-app-engine-datastore">This article</a> explains well how to integrate the servlet and cron job into your app to delete the sessions. But you should be aware that each of the servlet run can only remove 100 sessions at most, that means if you have a huge traffic and huge sessions, you have to set the servlet/cron job runs more frequently but also make sure you won&#8217;t interrupt any current user&#8217;s activities.</p>
<p>OK, it seems all working well except some bugs may happen. One of the issues we have detect is that we have some very very very old sessions being around, maybe one year (Before we include the clean session mechanism), and obviously no matter how many times of the session being cleaned by the servlet, those sessions will always survive from all bullets. While, we have no explaination about it and they are always so trivial to be neglect until a 500 error comes up when a new version being released.</p>
<p>One bug we recently have is after we change one of the property in a class type from String to Date, and accordingly some of the related methods are being updated as well. But those ghost sessions still have String in their hearts, and when app initialized, everything just crashed because of this catch. Consequently, we are thinking about maybe it is worthwhile to clean the cache whenever a new version being released, and this cannot being relied on the servlet provided by Google, but rather our own code to delete all of them. <a href="http://groups.google.com/group/google-appengine-java/browse_thread/thread/280c3fb95dac2314">This thread</a> elegantly handles above problem by deleting all sessions and caches using a customized code, and you can now have a clean environment whenever you want.</p>
<p>So once you have integrated above two points into your projects, you should no longer worry about any session issues, and hopefully Google will someday bring us a better built-in solution to handle all this issues. For now, let&#8217;s just work harder.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/google-app-engine/session-clean-in-google-app-engine/feed</wfw:commentRss>
		</item>
		<item>
		<title>Google App Engine: Found a jar file too large to upload</title>
		<link>http://www.featheast.com/en/wordpress/google-app-engine/google-app-engine-found-a-jar-file-too-large-to-upload</link>
		<comments>http://www.featheast.com/en/wordpress/google-app-engine/google-app-engine-found-a-jar-file-too-large-to-upload#comments</comments>
		<pubDate>Fri, 16 Sep 2011 07:24:44 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Google App Engine]]></category>

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

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

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

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=111</guid>
		<description><![CDATA[When deploying your application into the server, sometimes you may encounter this issue that if you have a really big JAR. This is not a common case before the release of 1.5.4, however, the latest appengine-tools-sdk-1.5.4.jar is about 9.7MB which exceeds the limit a little bit. I&#8217;m not sure if you use Eclipse&#8217;s plugin to [...]]]></description>
			<content:encoded><![CDATA[<p>When deploying your application into the server, sometimes you may encounter this issue that if you have a really big JAR. This is not a common case before the release of 1.5.4, however, the latest appengine-tools-sdk-1.5.4.jar is about 9.7MB which exceeds the limit a little bit. I&#8217;m not sure if you use Eclipse&#8217;s plugin to upload your application will be OK or not, but definitely when you try to use the maven plugin, an error will happen to notify you that the jar is too large to upload.</p>
<p>The fix for using standard upload is simple that add the provided parameter to the end of the command is fine.</p>
<p>For maven part, what you need to modify is your pom.xml:</p>
<p>&lt;plugin&gt;<br />
&lt;groupId&gt;net.kindleit&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-gae-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;${maven.gae.plugin.version}&lt;/version&gt;<br />
&lt;configuration&gt;<br />
<span style="color: #ff0000;">&lt;splitJars&gt;true&lt;/splitJars&gt;</span><br />
&lt;/configuration&gt;<br />
&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;net.kindleit&lt;/groupId&gt;<br />
&lt;artifactId&gt;gae-runtime&lt;/artifactId&gt;<br />
&lt;version&gt;${gae.version}&lt;/version&gt;<br />
&lt;type&gt;pom&lt;/type&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/plugin&gt;</p>
<p>The one with the red color is the thing that you need to add, are maven plugin will use the split jar pattern to upload the application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/google-app-engine/google-app-engine-found-a-jar-file-too-large-to-upload/feed</wfw:commentRss>
		</item>
		<item>
		<title>SQL: Turn multiple rows into one row multiple columns</title>
		<link>http://www.featheast.com/en/wordpress/uncategorized/sql-turn-multiple-rows-into-one-row-multiple-columns</link>
		<comments>http://www.featheast.com/en/wordpress/uncategorized/sql-turn-multiple-rows-into-one-row-multiple-columns#comments</comments>
		<pubDate>Sat, 25 Jun 2011 01:29:00 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=109</guid>
		<description><![CDATA[We have a table looks like this:
Name Question Value
Alan        1           5
Alan        2           4
Alan        3           6
Jim          1           4
Jim          2           3
Jim   [...]]]></description>
			<content:encoded><![CDATA[<p><span>We have a table looks like this:<br />
Name Question Value<br />
Alan        1           5<br />
Alan        2           4<br />
Alan        3           6<br />
Jim          1           4<br />
Jim          2           3<br />
Jim          4           5</p>
<p>We would like to select out a result looks like this:<br />
Name    Q1     Q2    Q3    Q4<br />
Alan       5        4       6      null<br />
Jim          4       3       null   5</p>
<p>This problem seems to be very easy, however, cost me a lot of time to figure out how to proceed. Finally, after some googling a nice post introduce a nice way to handle similar issues using MAX(DECODE()) function.</p>
<p>Basically, you first need to utilise the decode() function. decode() acts like if-else-then. For example, decode(name, &#8216;Alan&#8217;, &#8216;True&#8217;, &#8216;False&#8217;) works like if the name is &#8216;Alan&#8217; then return &#8216;True&#8217;, otherwise return &#8216;False&#8217;.</p>
<p>In our problem here, we use decode() to distinguish the answers from different questions: decode(question, 1, value, NULL) as Q1,   decode(question, 2, value, NULL) as Q2, &#8230; In this way we would pick out the value of each question.</p>
<p>After we can get the answer to each question, what we need to do is group the answers by different names. That&#8217;s why we need max() here to act for the group by clause. Since there is only one value here for each question, so max(), min() or some other reasonable functions are all working well here.:</p>
<p>select name AS NAME, max(decode(question, 1, value, NULL)) AS Q1, max(decode(question, 2, value, NULL)) AS Q2, max(decode(question, 3, value, NULL)) AS Q3, max(decode(question, 4, value, NULL)) AS Q4 from table group by name.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/uncategorized/sql-turn-multiple-rows-into-one-row-multiple-columns/feed</wfw:commentRss>
		</item>
		<item>
		<title>Cannot restart LDAP server on Ubuntu</title>
		<link>http://www.featheast.com/en/wordpress/uncategorized/cannot-restart-ldap-server-on-ubuntu</link>
		<comments>http://www.featheast.com/en/wordpress/uncategorized/cannot-restart-ldap-server-on-ubuntu#comments</comments>
		<pubDate>Wed, 25 May 2011 01:28:30 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=107</guid>
		<description><![CDATA[I did some changes to the ldif file yesterday, and cannot start my LDAP server any more today. I tried different ways, but all unfortunately failed.
Actually the way to workaround is quite easy, that you simply remove the folder slapd.d/ under /etc/ldap, and reinstall the ldap again, ldap will work again.
]]></description>
			<content:encoded><![CDATA[<p><span>I did some changes to the ldif file yesterday, and cannot start my LDAP server any more today. I tried different ways, but all unfortunately failed.</p>
<p>Actually the way to workaround is quite easy, that you simply remove the folder slapd.d/ under /etc/ldap, and reinstall the ldap again, ldap will work again.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/uncategorized/cannot-restart-ldap-server-on-ubuntu/feed</wfw:commentRss>
		</item>
		<item>
		<title>Intellij IDEA 10.5 stuck in the loading process</title>
		<link>http://www.featheast.com/en/wordpress/uncategorized/intellij-idea-105-stuck-in-the-loading-process</link>
		<comments>http://www.featheast.com/en/wordpress/uncategorized/intellij-idea-105-stuck-in-the-loading-process#comments</comments>
		<pubDate>Wed, 25 May 2011 01:27:54 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=105</guid>
		<description><![CDATA[Intellij IDEA is a really smart IDA that attracts more and more developers to its community. However, a lot of bugs are still hanging there which annoy people too much.
One of the bugs is when you start IDEA with a pretty large project, there is a highly chance that your loading process will stuck there [...]]]></description>
			<content:encoded><![CDATA[<p><span>Intellij IDEA is a really smart IDA that attracts more and more developers to its community. However, a lot of bugs are still hanging there which annoy people too much.</p>
<p>One of the bugs is when you start IDEA with a pretty large project, there is a highly chance that your loading process will stuck there forever. This has been identified as a bug in <a href="http://youtrack.jetbrains.net/issue/IDEA-67401">IDEA-67401</a>, and hasn&#8217;t been resolved yet now.</p>
<p>According to that issue page, there is a workaround to load the project. That is to disable the &#8216;Tip of the Day&#8217; and &#8216;Productivity Guide&#8217; prompt when start a new project or open IDEA.</p>
<p>Besides, there is another possibility that you cannot even get in to adjust your setting before it get stuck. If that is the case, just remember to be very quick when you open IDEA, as soon as the loading project prompt pop up, cancel the loading, as well as all the next loading processes. Once the loading started, you will not be able to cancel it again, and have to kill the IDE and restart again.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/uncategorized/intellij-idea-105-stuck-in-the-loading-process/feed</wfw:commentRss>
		</item>
		<item>
		<title>Oracle: To convert a row into a column (CROSS-JOIN)</title>
		<link>http://www.featheast.com/en/wordpress/uncategorized/oracle-to-convert-a-row-into-a-column-cross-join</link>
		<comments>http://www.featheast.com/en/wordpress/uncategorized/oracle-to-convert-a-row-into-a-column-cross-join#comments</comments>
		<pubDate>Tue, 17 May 2011 01:27:01 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=103</guid>
		<description><![CDATA[This afternoon, while I am doing some Jasper report stuff, I am puzzled by a SQL query that which takes quite a long time to execute. As the time goes, Jasper will easily get a timeout and a blank screen is waiting for me after retrieving data for about 120 seconds.
As it is not appropriate [...]]]></description>
			<content:encoded><![CDATA[<p><span>This afternoon, while I am doing some Jasper report stuff, I am puzzled by a SQL query that which takes quite a long time to execute. As the time goes, Jasper will easily get a timeout and a blank screen is waiting for me after retrieving data for about 120 seconds.</p>
<p>As it is not appropriate to use the original data table as the example to describe here, I tried to make up a similar scenario which should explain the cause and the solution sufficiently.</p>
<p>Given a table A, with five columns &#8212; Primary Key (pk), Statistics 1A (s1a), Statistics 1B (s1b), Statistics 2A(s2a), Statistics 2B(s2b), we need to select the data out into a form that looks like &#8212; Primary Key (pk), Statistics A(s1a or s2a), Statistics B(s2b or s2b). Essentially, it is trying to convert a row into one column but two rows.  Someone may prefer to call it pivot query by the way.</p>
<p>Initially, naively I think the most easiest and intuitive way to do it is by two union queries. That is<br />
select pk, s1a, s1b from table where *** union select pk, s2a, s2b from table where ***.<br />
When the data set is small, and it only depends on the single table, it is fine. However, in my case, the data set is huge, and the union will not be two but eight, and more importantly every union section will consists of another 6 inner join tables. That&#8217;s the reason why Jasper cannot retrieve what it needs on time.</p>
<p><a href="http://www.dba-oracle.com/t_converting_rows_columns.htm">In this link</a>, as suggested by Scott, introduced a very smart way to handle this issue. What it uses is called: cross join. So basically, we use the existing table to cross join with the different type/criteria to return the expected result.</p>
<p>select<br />
pk,<br />
case<br />
when ite = &#8217;s1&#8242; then s1a<br />
when ite = &#8217;s2&#8242; then s2a<br />
end as sa<br />
case<br />
when ite = &#8217;s1&#8242; then s1b<br />
when ite = &#8217;s2&#8242; then s2b<br />
end as sb<br />
from<br />
(<br />
select pivoter.ite,<br />
s1a, s1b, s2a, s2b<br />
from<br />
table<br />
cross join (<br />
select &#8217;s1&#8242; as ite from dual<br />
union all<br />
select &#8217;s2&#8242; as ite from dual<br />
) pivotel<br />
)</p>
<p>By using the above code, the problem will be solved by the cross join union columns.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/uncategorized/oracle-to-convert-a-row-into-a-column-cross-join/feed</wfw:commentRss>
		</item>
		<item>
		<title>Miscellaneous Points for Oracle Join Query</title>
		<link>http://www.featheast.com/en/wordpress/uncategorized/miscellaneous-points-for-oracle-join-query</link>
		<comments>http://www.featheast.com/en/wordpress/uncategorized/miscellaneous-points-for-oracle-join-query#comments</comments>
		<pubDate>Mon, 16 May 2011 01:25:59 +0000</pubDate>
		<dc:creator>featheast</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.featheast.com/en/wordpress/?p=100</guid>
		<description><![CDATA[As a software developer, you must have the experience to deal with all sorts of join queries. And I believe everyone has once or still now struggle with all these different terms about inner, outer, left, right, and etc. As I have spent roughly two hours these morning, to summarize some of the points that [...]]]></description>
			<content:encoded><![CDATA[<p><span>As a software developer, you must have the experience to deal with all sorts of join queries. And I believe everyone has once or still now struggle with all these different terms about inner, outer, left, right, and etc. As I have spent roughly two hours these morning, to summarize some of the points that I am easily to forgotten and got wrong, it&#8217;s a good chance to write it done in case later I need to test my memory.</span></p>
<p>1) What is the difference of join&#8230;on&#8230; grammar and little (+) sign?</p>
<p>Oracle used to only support (+) in old days, which is also kind of created by Oracle. Later, as the ANSI formalized the standard for join grammar, Oracle adopted both for join queries. As a result, it won&#8217;t be a surprise if you see both two styles in your project which comes from different developers.</p>
<p>2) Any difference between inner join and join?</p>
<p>No.</p>
<p>3) Why do we need outer join?</p>
<p>Generally, inner join will return result sets that have a match in both Table A and B. However in reality sometimes, we also need results to be returned even the matching is null. That&#8217;s the place where outer join shows its ability. There are plenty of tutorials available to discuss about the outer join. What I want to mentioning here is the null value will only applied to the join&#8217;s destination table, but not the starting table.</p>
<p>4) Any more differences?</p>
<p>Yes. Actually there are two more I want to emphasize:</p>
<p>1. ANSI style supports outer join, which you can google what does it mean. But traditional Oracle doesn&#8217;t directly support it. ( By saying it directly, I mean there always exists workarounds, and various workarounds)<br />
2. One of the most important feature to differentiate the two is the ANSI style separate the join condition and query filter criteria, which is much more nice tidy and clean. (Is it, at least I think so). Meanwhile, you will also be able to avoid a lot of caveats that may come with you when you go for the traditional style. See <a href="http://www.orafaq.com/node/855">Common errors seen when using OUTER-JOIN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.featheast.com/en/wordpress/uncategorized/miscellaneous-points-for-oracle-join-query/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

