Here's the sample SQL:
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)
The error only appears when I use GROUP BY
to do a count. When it is removed I get the error
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
Is GROUP BY
somehow mutating the type of the XML field returned in the sub query? Or (more than likely) am I just missing something?
It is worth noting that the source_table.data
column is a CLOB.