<?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"
	>
<channel>
	<title>Comments on: How to determine if the formula string contains balanced pairs of parentheses in SQL</title>
	<atom:link href="http://oraqa.com/2008/06/08/how-to-determine-if-the-formula-string-contains-balanced-pairs-of-parentheses-in-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2008/06/08/how-to-determine-if-the-formula-string-contains-balanced-pairs-of-parentheses-in-sql/</link>
	<description>Oracle Question and Answer</description>
	<pubDate>Thu, 20 Nov 2008 23:04:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Frank Zhou</title>
		<link>http://oraqa.com/2008/06/08/how-to-determine-if-the-formula-string-contains-balanced-pairs-of-parentheses-in-sql/#comment-239</link>
		<dc:creator>Frank Zhou</dc:creator>
		<pubDate>Tue, 10 Jun 2008 14:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=258#comment-239</guid>
		<description>Gmyers,
     
       Your simpler method doesn't work,
it didn't put all cases into consideration.

For example when str_num = '1+)2+(3+4'


SQL&#62; select str_num,
  2  case when length(replace(str_num,')')) = length(replace(str_num,'('))
  3  then 'T' else 'F' end bal
  4  from ( select '1+)2+(3+4' str_num from dual);

STR_NUM   BAL
--------- -----
1+)2+(3+4 T

The correct answer should be "F".

Frank</description>
		<content:encoded><![CDATA[<p>Gmyers,</p>
<p>       Your simpler method doesn&#8217;t work,<br />
it didn&#8217;t put all cases into consideration.</p>
<p>For example when str_num = &#8216;1+)2+(3+4&#8242;</p>
<p>SQL&gt; select str_num,<br />
  2  case when length(replace(str_num,&#8217;)')) = length(replace(str_num,&#8217;('))<br />
  3  then &#8216;T&#8217; else &#8216;F&#8217; end bal<br />
  4  from ( select &#8216;1+)2+(3+4&#8242; str_num from dual);</p>
<p>STR_NUM   BAL<br />
&#8212;&#8212;&#8212; &#8212;&#8211;<br />
1+)2+(3+4 T</p>
<p>The correct answer should be &#8220;F&#8221;.</p>
<p>Frank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gmyers</title>
		<link>http://oraqa.com/2008/06/08/how-to-determine-if-the-formula-string-contains-balanced-pairs-of-parentheses-in-sql/#comment-238</link>
		<dc:creator>gmyers</dc:creator>
		<pubDate>Mon, 09 Jun 2008 23:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=258#comment-238</guid>
		<description>Or a simple
select str_num,
        case when length(replace(str_num,')')) = length(replace(str_num,'(')) 
            then 'T' else 'F' end bal
from test</description>
		<content:encoded><![CDATA[<p>Or a simple<br />
select str_num,<br />
        case when length(replace(str_num,&#8217;)')) = length(replace(str_num,&#8217;('))<br />
            then &#8216;T&#8217; else &#8216;F&#8217; end bal<br />
from test</p>
]]></content:encoded>
	</item>
</channel>
</rss>
