Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Querying CLOB column (with XML content)

Veera_VSep 2 2014 — edited Sep 5 2014

1. How to extract a particular xml tag value from a column with CLOB datatype.

Example:

<REQUEST_DETAIL>

  <GROUP_TYPE>PR</GROUP_TYPE>

  <GROUP_NAME>DATA ENGINEERING ASSET MANAGEMENT</GROUP_NAME>

   <BUS_UNIT_ACRN>SCS-FCAT</BUS_UNIT_ACRN>

   <PROJ_MGR_ID></PROJ_MGR_ID>

  <PROJ_MGR_NAME>Roland Roy</PROJ_MGR_NAME>

  </REQUEST_DETAIL>

select

xmltype(e.x).extract('/REQUEST_DETAIL/GROUP_TYPE/text()').getStringVal()

  from t e

/

above example works.

If I dont know the order of xml tag to be queried how can I get the value.

(*****/****/***/***/REQUEST_DETAIL/GROUP_TYPE/***/**** )

2.using DBMS_LOB.SUBSTR is taking more time to execute and it never return results and session goes wait status for accesing LOB_INDEX (concurrently the CLOB column  is used by application).

Is there any other option to get the results quicker.

SELECT DBMS_LOB.SUBSTR (xml_blob, 4, DBMS_LOB.INSTR (xml_blob, '<Name>', 1, 1 ) + 6 ) name,

        status,

        COUNT (*) cnt

         FROM LOG_TBL

     WHERE TRUNC(IO_DATE)=TRUNC(SYSDATE)

             GROUP BY DBMS_LOB.SUBSTR (xml_blob, 4, DBMS_LOB.INSTR (xml_blob, '<Name>', 1, 1 ) + 6 ),

        status

Regards,

Veera

This post has been answered by chris227 on Sep 4 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2014
Added on Sep 2 2014
27 comments
9,687 views