title: oracle XMLTABLE is not working as expected
body: <p>I was using EXTRACT method to extract the values from XML type column in Oracle 11g database.</p>
  
  <p>If my table has 10 rows,
  as EXTRACT is used in the select clause, when i put some condition in XPATH like </p>
  
  <pre><code>'/Items/OperatingSystem/@Version[contains(.,"4.04")]'
  </code></pre>
  
  <p>In the returned rows, it shows the null if the XPATH expression is not matching, but it shows all 10 rows.</p>
  
  <p>So I tried to moved to XMLTABLE as I found this is the latest (EXTRACT is deprecated) As we know it is used in FROM clause. I tried few basic queries and found it only return rows which has match with the XPATH expression.(skips the null rows returned in case of EXTRACT case)</p>
  
  <p>One strange issue I found using XMLTABLE is -
  In my local environment, when I use the XPATH expression </p>
  
  <pre><code>'/Items/OperatingSystem/@Version[contains(.,"4.04")]'
  </code></pre>
  
  <p>In result, it selects only the rows having Name containing 'Dee' in it.</p>
  
  <p>But when I run the same query against our testing environments</p>
  
  <p>It selects all the rows instead of only selecting having Name containing 'Dee'.
  I could not find any hint why this is happening. I tried few more queries putting condition on other fields like Age etc.. but the result is same. It is returning all rows.</p>
  
  <p>Here are the version details - 
  Local Oracle Version - </p>
  
  <pre><code>Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
  PL/SQL Release 11.2.0.2.0 - Production
  "CORE   11.2.0.2.0  Production"
  TNS for 64-bit Windows: Version 11.2.0.2.0 - Production
  NLSRTL Version 11.2.0.2.0 - Production
  </code></pre>
  
  <p>Testing Environment Oracle Version -</p>
  
  <pre><code>Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  PL/SQL Release 11.2.0.3.0 - Production
  "CORE   11.2.0.3.0  Production"
  TNS for HPUX: Version 11.2.0.3.0 - Production
  NLSRTL Version 11.2.0.3.0 - Production
  </code></pre>
  
  <p>Are there any changes related to XMLTABLE in these versions.</p>
  
  <p><strong>Sample Data</strong></p>
  
  <p>Suppose I have the following table </p>
  
  <pre><code>NAME    | XMLDATA       |   CRT_TS
  Ubuntu  | UbuntuXMLDATA | 20-OCT-2016
  Windows | WindowsXMLDATA| 20-OCT-2016
  </code></pre>
  
  <p>UbuntuXMLDATA</p>
  
  <pre><code>&lt;Items&gt;
  &lt;OperatingSystem Name="Ubuntu 12.04" Version="12.04" /&gt;
  &lt;OperatingSystem Name="Ubuntu 14.04" Version="14.04" /&gt;
  &lt;OperatingSystem Name="Ubuntu 16.04" Version="16.04" /&gt;
  &lt;/Items&gt;
  </code></pre>
  
  <p>WindowsXMLDATA</p>
  
  <pre><code>&lt;Items&gt;
  &lt;OperatingSystem Name="Windows" Version="8" /&gt;
  &lt;OperatingSystem Name="Windows" Version="7" /&gt;
  &lt;/Items&gt;
  </code></pre>
  
  <p>In table, above xmls are present in column XMLDATA.</p>
  
  <p><strong>Query</strong></p>
  
  <pre><code>select Name,rx.COLUMN_VALUE as XPATH_OUTPUT from Operating_System, XMLTABLE('/Items/OperatingSystem/@Version[contains(.,"4.04")]' PASSING XMLTYPE(XMLDATA)) rx where CRT_TS = 20-OCT-2016;
  </code></pre>
  
  <p><strong>Expected Result</strong></p>
  
  <pre><code>Name    | XPATH_OUTPUT
  Ubuntu  | 14.04
  </code></pre>
  
  <p><strong>Actual Result</strong></p>
  
  <pre><code>Name    | XPATH_OUTPUT
  Ubuntu  | 12.04
  Ubuntu  | 14.04
  Ubuntu  | 16.04
  </code></pre>
  
  <p>The issue I am facing is the above query is working fine in my local database.
  But against testing environment It is returning three rows instead of one. I am not able to figure out Why? Is is due to Oracle version (I have given the details above) mismatch?</p>