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!

how to extract the xmltype (the node with value only)

helooFeb 20 2019 — edited Apr 16 2019

i have table with 2 column, 1st=id as number, 2nd=xmlcol as xmltype

table name TBL

id        xmlcol

-----     ------------------------------------------------------------------------------------------------

1         <a1>2</a1><a2>d</a2><a4>d</a4><a4 m='2'>d</a4>

2         <a1></a1><a2>d</a2><a4>d</a4><a4 m='2'>d</a4>

3         <a2>d</a2><a4>d</a4><a4 m='2'>d</a4>

4         <a1>2</a1><a1 m='2'>4</a1><a2>d</a2><a4>d</a4><a4 m='2'>d</a4>

5         <a1>2</a1><a1 m='2'>4</a1><a2>d</a2><a4>d</a4><a4 m='2'>d</a4>

6         <a3>add</a3>

output

----------

id

1

4

5

6

SELECT * FROM TBL

WHERE XMLEXISTS('/row/a1[text()=20180118]' PASSING XMLDOC)

---------------------

how can i retrieve the record which is not null or not empty for a1 node? (how can i prepare script that i can retrieve <a1> or <a3> node with value , not equal to null and not empty)

Comments
Post Details
Added on Feb 20 2019
14 comments
458 views