Reputation: 125
select a.test
from demotable b
,XMLTable('//test' passing xmltype(b.xmlTagColumn) columns test varchar(10) path '.') a
b.xmlTagColumn has xml content.
If b.xmlTagColumn has <test></test>
then I am not getting anything from above statement not even null. How can I get null or dummy value for empty tag?
Upvotes: 1
Views: 1235
Reputation: 44921
left join ... on 1=1
select a.test
from demotable b
left join XMLTable
(
'//test'
passing xmltype(b.xmlTagColumn)
columns
test varchar(10) path '.'
) a
on 1=1
;
Demo
create table demotable (id int,xmlTagColumn varchar2(100));
insert into demotable (id,xmlTagColumn) values (1,'<X><test>123</test></X>');
insert into demotable (id,xmlTagColumn) values (2,'<Y><test>456</test></Y>');
insert into demotable (id,xmlTagColumn) values (3,'<Z><prod>123</prod></Z>');
select b.id
,a.test
from demotable b
left join XMLTable
(
'//test'
passing xmltype(b.xmlTagColumn)
columns
test varchar(10) path '.'
) a
on 1=1
;
+----+--------+
| ID | TEST |
+----+--------+
| 1 | 123 |
+----+--------+
| 2 | 456 |
+----+--------+
| 3 | (null) |
+----+--------+
Upvotes: 1