title: Doing a pl/sql GROUP BY on an XML field gives "ORA-22806: not an object or REF"
body: <p>Here's the sample SQL:</p>
  
  <pre><code>SELECT xml_data.field
  FROM
    (SELECT sys.XMLType(source_table.data).extract('//source_node/text()') AS field
    FROM source_table
    )xml_data
  GROUP BY to_clob(xml_data.field)
  </code></pre>
  
  <p>The error only appears when I use <code>GROUP BY</code> to do a count. When it is removed I get the error</p>
  
  <pre><code>ORA-22806: not an object or REF
  22806. 00000 - "not an object or REF"
  *Cause: An attempt was made to extract an attribute from an
          item that is neither an object nor a REF.
  *Action: Use an object type or REF type item and retry the operation.
  Vendor code 22804Error at Line:1
  </code></pre>
  
  <p>Is <code>GROUP BY</code> somehow mutating the type of the XML field returned in the sub query? Or (more than likely) am I just missing something?</p>
  
  <p>It is worth noting that the <code>source_table.data</code> column is a CLOB.</p>