<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Feeling ANSI About Oracle Join Syntax?</title>
	<atom:link href="http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Mon, 13 May 2013 14:10:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2521</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Tue, 28 Dec 2010 12:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2521</guid>
		<description><![CDATA[William (and Tim),

Thank you for taking the time to reformat the SQL statement, demonstrating your formatting approach for ANSI style SQL statements.  When there are three or more tables accessed, your formatting approach helps considerably to improve readability.  

Also, thank you for helping to add value to this blog article.]]></description>
		<content:encoded><![CDATA[<p>William (and Tim),</p>
<p>Thank you for taking the time to reformat the SQL statement, demonstrating your formatting approach for ANSI style SQL statements.  When there are three or more tables accessed, your formatting approach helps considerably to improve readability.  </p>
<p>Also, thank you for helping to add value to this blog article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Robertson</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2517</link>
		<dc:creator><![CDATA[William Robertson]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 17:37:44 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2517</guid>
		<description><![CDATA[...of course, that&#039;s just the readability aspect. It is rather worrying to read about ANSI join bugs in 11g - I had rather hoped they mostly went away around 9.2.  I haven&#039;t come across one myself. And of course as Jonathan Lewis mentioned recently, the implementation adds an internal transformation that can lead to odd &#039;why is my hint being ignored?&#039; issues (though there are enough of those already for me to be pretty much expecting them these days).]]></description>
		<content:encoded><![CDATA[<p>&#8230;of course, that&#8217;s just the readability aspect. It is rather worrying to read about ANSI join bugs in 11g &#8211; I had rather hoped they mostly went away around 9.2.  I haven&#8217;t come across one myself. And of course as Jonathan Lewis mentioned recently, the implementation adds an internal transformation that can lead to odd &#8216;why is my hint being ignored?&#8217; issues (though there are enough of those already for me to be pretty much expecting them these days).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Robertson</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2516</link>
		<dc:creator><![CDATA[William Robertson]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 17:28:47 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2516</guid>
		<description><![CDATA[That&#039;s pretty much what I use. I got into the habit of upper-casing keywords twenty or so years ago, but part of me secretly likes all-lowercase (more than all-uppercase, certainly). I would just add one more blank line before &#039;join cust_order_line&#039;. Like Tim, I quite like one line per join clause when it&#039;s simple but switch to multi-line at the first sign of complexity. I would tend to do the lot, i.e. a new line before all ON clauses. I appreciate this leaves the table list un-aligned (customer, cust_order, shipper etc start at different places) which I regret as I like a neat list, but I still think the resulting ANSI FROM clause walks you through the joins better than the old way. It&#039;s also much easier to switch between inner and outer joins when tracing a &quot;why am I getting no rows back?&quot; problem.

I would also place each new table&#039;s column first in its ON condition for reasons done to death here: http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity, but basically to be consistent with &#039;where empno = 7839&#039; and &#039;where deptno is not null&#039; type of constructions (i.e. rather than &#039;where 7839 = empno&#039; and, umm, &#039;where null is not deptno&#039;). Apparently some people&#039;s brains are wired the other way around to mine, but I always have to edit the code to read that way before I can make any sense of it. That gives me a FROM clause along the lines of:

[code]FROM   customer_order co

       JOIN cust_order_line col
       ON   col.cust_order_id = co.id

       JOIN part p
       ON   p.id = col.part_id

       LEFT JOIN shipper_line sl
       ON   sl.cust_order_id = col.cust_order_id
       AND  sl.cust_order_line_no = col.line_no

       LEFT JOIN shipper s
       ON   s.packlist_id = sl.packlist_id

WHERE  COALESCE(sl.shipped_qty,1) &gt; 0
AND    p.description LIKE &#039;PUMP%&#039;;[/code]]]></description>
		<content:encoded><![CDATA[<p>That&#8217;s pretty much what I use. I got into the habit of upper-casing keywords twenty or so years ago, but part of me secretly likes all-lowercase (more than all-uppercase, certainly). I would just add one more blank line before &#8216;join cust_order_line&#8217;. Like Tim, I quite like one line per join clause when it&#8217;s simple but switch to multi-line at the first sign of complexity. I would tend to do the lot, i.e. a new line before all ON clauses. I appreciate this leaves the table list un-aligned (customer, cust_order, shipper etc start at different places) which I regret as I like a neat list, but I still think the resulting ANSI FROM clause walks you through the joins better than the old way. It&#8217;s also much easier to switch between inner and outer joins when tracing a &#8220;why am I getting no rows back?&#8221; problem.</p>
<p>I would also place each new table&#8217;s column first in its ON condition for reasons done to death here: <a href="http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity" rel="nofollow">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity</a>, but basically to be consistent with &#8216;where empno = 7839&#8242; and &#8216;where deptno is not null&#8217; type of constructions (i.e. rather than &#8216;where 7839 = empno&#8217; and, umm, &#8216;where null is not deptno&#8217;). Apparently some people&#8217;s brains are wired the other way around to mine, but I always have to edit the code to read that way before I can make any sense of it. That gives me a FROM clause along the lines of:</p>
<pre class="brush: plain; title: ; notranslate">FROM   customer_order co

       JOIN cust_order_line col
       ON   col.cust_order_id = co.id

       JOIN part p
       ON   p.id = col.part_id

       LEFT JOIN shipper_line sl
       ON   sl.cust_order_id = col.cust_order_id
       AND  sl.cust_order_line_no = col.line_no

       LEFT JOIN shipper s
       ON   s.packlist_id = sl.packlist_id

WHERE  COALESCE(sl.shipped_qty,1) &gt; 0
AND    p.description LIKE 'PUMP%';</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2515</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 13:54:31 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2515</guid>
		<description><![CDATA[Thanks for the compliment, Martin.  I have plenty of answers for questions that I do not yet know (a solution in search of the perfect problem).  :-)]]></description>
		<content:encoded><![CDATA[<p>Thanks for the compliment, Martin.  I have plenty of answers for questions that I do not yet know (a solution in search of the perfect problem).  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2514</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 13:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2514</guid>
		<description><![CDATA[Tim,

Thanks for stopping by and for reformatting my SQL statement.  I am still trying to find the best format for ANSI style SQL statements - I like the ability of vertically scanning a SQL statement to be able to pick out the list of tables that are involved in the SQL statement, as I am able to do with the Oracle specific join syntax.  That approach seems to make a mess when applied to ANSI syntax (maybe I just need to indent the ON clause another 4 spaces).  Your reformatted version of the SQL statement is easier on the eyes than my version - but I still miss the ability to quickly see the list of tables and the restrictions applied to each table.  :-)

I am a little surprised how many ANSI related bugs are fixed in 11.2.0.2 or 12.1, but then I suppose that each transformation that a typical SQL statement using Oracle syntax is subjected to must also be considered for those SQL statements using ANSI syntax (if the transformation typically happens before the ANSI to Oracle syntax conversion) - if 11.2.0.1 introduces a new transformation to better optimize a SQL statement, it could potentially break the ANSI equivalent SQL statement.]]></description>
		<content:encoded><![CDATA[<p>Tim,</p>
<p>Thanks for stopping by and for reformatting my SQL statement.  I am still trying to find the best format for ANSI style SQL statements &#8211; I like the ability of vertically scanning a SQL statement to be able to pick out the list of tables that are involved in the SQL statement, as I am able to do with the Oracle specific join syntax.  That approach seems to make a mess when applied to ANSI syntax (maybe I just need to indent the ON clause another 4 spaces).  Your reformatted version of the SQL statement is easier on the eyes than my version &#8211; but I still miss the ability to quickly see the list of tables and the restrictions applied to each table.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I am a little surprised how many ANSI related bugs are fixed in 11.2.0.2 or 12.1, but then I suppose that each transformation that a typical SQL statement using Oracle syntax is subjected to must also be considered for those SQL statements using ANSI syntax (if the transformation typically happens before the ANSI to Oracle syntax conversion) &#8211; if 11.2.0.1 introduces a new transformation to better optimize a SQL statement, it could potentially break the ANSI equivalent SQL statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2513</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 13:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2513</guid>
		<description><![CDATA[Hi William,

Thank you for the comment and the suggested reformatting.  I adopted the rather rigid uppercase formatting/indenting roughly 10 or 11 years ago, and that formatting doesn&#039;t seem to flow well for the ANSI style join syntax.  With the following as your starting point, how would you adjust the formatting to make the ANSI style join easier to read? 
[code]
select
  co.id,
  s.shipped_date,
  col.line_no,
  p.id,
  p.description,
  sl.shipped_qty
from
  customer_order co
  join cust_order_line col on co.id=col.cust_order_id
 
  join part p on col.part_id=p.id
 
  left join shipper_line sl on col.cust_order_id=sl.cust_order_id
    and col.line_no=sl.cust_order_line_no
 
  left join shipper s on sl.packlist_id=s.packlist_id
where
  coalesce(sl.shipped_qty,1) &gt; 0
  and p.description like &#039;PUMP%&#039;;
[/code]

If you would like to include a formatted code section in your reply, please use a code tag in square brackets before the section and a /code tag in square brackets after the section.]]></description>
		<content:encoded><![CDATA[<p>Hi William,</p>
<p>Thank you for the comment and the suggested reformatting.  I adopted the rather rigid uppercase formatting/indenting roughly 10 or 11 years ago, and that formatting doesn&#8217;t seem to flow well for the ANSI style join syntax.  With the following as your starting point, how would you adjust the formatting to make the ANSI style join easier to read? </p>
<pre class="brush: plain; title: ; notranslate">
select
  co.id,
  s.shipped_date,
  col.line_no,
  p.id,
  p.description,
  sl.shipped_qty
from
  customer_order co
  join cust_order_line col on co.id=col.cust_order_id
 
  join part p on col.part_id=p.id
 
  left join shipper_line sl on col.cust_order_id=sl.cust_order_id
    and col.line_no=sl.cust_order_line_no
 
  left join shipper s on sl.packlist_id=s.packlist_id
where
  coalesce(sl.shipped_qty,1) &gt; 0
  and p.description like 'PUMP%';
</pre>
<p>If you would like to include a formatted code section in your reply, please use a code tag in square brackets before the section and a /code tag in square brackets after the section.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Robertson</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2512</link>
		<dc:creator><![CDATA[William Robertson]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 09:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2512</guid>
		<description><![CDATA[Following on from Tim&#039;s point, it also doesn&#039;t help that your examples are all in uppercase and you are using the AFAIK redundant OUTER and INNER keywords. (Are they required in SQL Server?) I just write JOIN and LEFT JOIN (while cursing the geniuses who came up with those meaningless keywords). I also add a blank line around each join clause, and indent them all so that the SELECT-FROM-WHERE structure is clearly visible.]]></description>
		<content:encoded><![CDATA[<p>Following on from Tim&#8217;s point, it also doesn&#8217;t help that your examples are all in uppercase and you are using the AFAIK redundant OUTER and INNER keywords. (Are they required in SQL Server?) I just write JOIN and LEFT JOIN (while cursing the geniuses who came up with those meaningless keywords). I also add a blank line around each join clause, and indent them all so that the SELECT-FROM-WHERE structure is clearly visible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Berger</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2511</link>
		<dc:creator><![CDATA[Martin Berger]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 08:54:02 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2511</guid>
		<description><![CDATA[Thank you for the elaborated blog! 
Once again you answered more questions than I initially asked ;-)]]></description>
		<content:encoded><![CDATA[<p>Thank you for the elaborated blog!<br />
Once again you answered more questions than I initially asked <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Hall</title>
		<link>http://hoopercharles.wordpress.com/2010/12/26/feeling-ansi-about-oracle-join-syntax/#comment-2506</link>
		<dc:creator><![CDATA[Tim Hall]]></dc:creator>
		<pubDate>Sun, 26 Dec 2010 16:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4133#comment-2506</guid>
		<description><![CDATA[Hi.

Funny. I would say the opposite in terms of readability. I think the ANSI way is mush more readable than the Oracle way. I switched almost as soon as it became available in 9i. Probably the biggest thing that &quot;turned&quot; me was dealing with developers from a multi-engine background. It just got easier to use ANSI than having to keep reminding people what all the (+) signs meant. :)

I know formatting is a personal thing, but I think the formatting you use makes it very difficult to read. I think of each join as a single line in the from clause If the line gets too wide then I wrap it, but if possible it stays on the same line. So that statement you listed that looked a total nightmare would look like this.

&lt;pre&gt;
SELECT
  CO.ID,
  S.SHIPPED_DATE,
  COL.LINE_NO,
  P.ID,
  P.DESCRIPTION,
  SL.SHIPPED_QTY
FROM
  CUSTOMER_ORDER CO
  INNER JOIN CUST_ORDER_LINE COL ON CO.ID=COL.CUST_ORDER_ID
  INNER JOIN PART P ON COL.PART_ID=P.ID
  LEFT OUTER JOIN SHIPPER_LINE SL ON COL.CUST_ORDER_ID=SL.CUST_ORDER_ID
    AND COL.LINE_NO=SL.CUST_ORDER_LINE_NO
  LEFT OUTER JOIN SHIPPER S ON SL.PACKLIST_ID=S.PACKLIST_ID
WHERE
  COALESCE(SL.SHIPPED_QTY,1) &gt; 0
  AND P.DESCRIPTION LIKE &#039;PUMP%&#039;; &lt;/pre&gt;

Pretty simple. Of course, if you don&#039;t like the ANSI syntax you probably still think it looks like a nightmare. :)

I agree the bug thing is a bit of a problem. In one of the 10g versions you had to write all outer joins as left outer joins because right outer joins just didn&#039;t work. :)

Cheers

Tim...]]></description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>Funny. I would say the opposite in terms of readability. I think the ANSI way is mush more readable than the Oracle way. I switched almost as soon as it became available in 9i. Probably the biggest thing that &#8220;turned&#8221; me was dealing with developers from a multi-engine background. It just got easier to use ANSI than having to keep reminding people what all the (+) signs meant. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I know formatting is a personal thing, but I think the formatting you use makes it very difficult to read. I think of each join as a single line in the from clause If the line gets too wide then I wrap it, but if possible it stays on the same line. So that statement you listed that looked a total nightmare would look like this.</p>
<pre>
SELECT
  CO.ID,
  S.SHIPPED_DATE,
  COL.LINE_NO,
  P.ID,
  P.DESCRIPTION,
  SL.SHIPPED_QTY
FROM
  CUSTOMER_ORDER CO
  INNER JOIN CUST_ORDER_LINE COL ON CO.ID=COL.CUST_ORDER_ID
  INNER JOIN PART P ON COL.PART_ID=P.ID
  LEFT OUTER JOIN SHIPPER_LINE SL ON COL.CUST_ORDER_ID=SL.CUST_ORDER_ID
    AND COL.LINE_NO=SL.CUST_ORDER_LINE_NO
  LEFT OUTER JOIN SHIPPER S ON SL.PACKLIST_ID=S.PACKLIST_ID
WHERE
  COALESCE(SL.SHIPPED_QTY,1) &gt; 0
  AND P.DESCRIPTION LIKE 'PUMP%'; </pre>
<p>Pretty simple. Of course, if you don&#8217;t like the ANSI syntax you probably still think it looks like a nightmare. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I agree the bug thing is a bit of a problem. In one of the 10g versions you had to write all outer joins as left outer joins because right outer joins just didn&#8217;t work. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers</p>
<p>Tim&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
