Skip to content
Advertisement

How to select part of the CLOB column with SQL

I am trying to get part of data from CLOB column which contain XML.

I need this because I want to create a report based on this data.

Table structure:

DIAGRAM ( ID number, XML clob );

XML example:

I want get this results:

Thanks in advance!

Advertisement

Answer

The main problem is that your XML is invalid. It’s missing the <?xml..> line, and it doesn’t have a root element, much less declare the namespaces. You’ll need to add those if you want to use Oracle’s XML functions.

But if you fix your XML, it’s not too bad.

Output:

Note that the xmlnamespaces() call should match your bpmn namespace declaration URL. Also, I’m just following the typical Oracle example of using a cross join with XMLTABLE(). If you want to run this for multiple rows in table DIAGRAM at the same time, you’ll need to modify that.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement