Operator and condition precedence

  • From: "Rich Jesse" <rjoralist@xxxxxxxxxxxxxxxxxxxxx>
  • To: "Oracle L" <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 8 Sep 2009 15:49:39 -0500 (CDT)

Hey all,

A coworker asks me about casting an NCHAR column to NUMBER in a query on
10.1.0.5.0 (AIX), so I of course offer up the syntax of TO_NUMBER.  Somewhat
knowing the data, I warn that conversions on columns of all spaces will
fail.  But for some reason, this works:

select aa.stuff, bb.stuff
from table_a aa,
     table_b bb
where aa.col_1a = bb.col_1b
  and to_number(aa.col_2a) = bb.col_2b
  and aa.col_3a = bb.col_3b
  and aa.col_4b = bb.col_4b
  and aa.col_6a in ('YY','ZZ')
  and aa.col_2a > ' '
  and aa.col_5a <> bb.col_5b;

Looking at the docs:

http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/conditions001.htm#sthref874

...tells me that the above would attempt to convert an AA.COL_2A to a number
before filtering it out from the AA.COL_2A > ' ' part, but it obviously
doesn't.  And there are known values of AA.COL_2A where it's all spaces.

The above statement works.  My question is "How?"

Thanks!
Rich


--
//www.freelists.org/webpage/oracle-l


Other related posts: