0

This is my XML Content stored same as it is in a Column name "Xml_Column" in the table "TEST_TABLE" and the data type of the column is clob.

<ns0:TEST_EVENTS xmlns:ns0="http://TEST.APPLICATION.ABC.Schemas.XML_Target_TESTEvents">
   <compname>Sherlock</compname>
        <Add>Homes</Add>
    <Employee>
        <firstname>Jim</firstname>
        <lastname>Moriarty</lastname>
        <age>52</age>
        <email>[email protected]</email>
    </Employee>
</ns0:TEST_EVENTS>

My requirement is to fetch the firstname and last name from this column where my xml content is stored and display. Any help

2

2 Answers 2

0

Use EXTRACTVALUE, it's a simpliest way: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions052.htm

For optimization, you should make inner query for constructing XMLType instance based on your clob; in the outer query use EXTRACTVALUE to select every value you wish.

Sign up to request clarification or add additional context in comments.

Comments

0

For example:

  SELECT extractValue(OBJECT_VALUE, '/firstname'),
         extractValue(OBJECT_VALUE, '/lastname')
         FROM TEST_TABLE;

All firstname and lastname:

SELECT  XMLQuery('for $d in /Employee
             return ($d/firstname/text(),$d/lastname/text())
            PASSING OBJECT_VALUE
            RETURNING CONTENT) FROM TEST_TABLE;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.