如何使用Oracle获取表中XML空标记的虚拟值?

时间:2016-12-07 05:26:23

标签: sql xml oracle

select a.test 
from demotable b
    ,XMLTable('//test' passing xmltype(b.xmlTagColumn) columns test varchar(10) path '.') a

b.xmlTagColumn具有xml内容。 如果b.xmlTagColumn有<test></test>,那么我从上面的语句中得不到任何东西,甚至不是null。如何为空标记获取空值或虚值?

1 个答案:

答案 0 :(得分:1)

$scope.$watch("picFile", function(value) { if (value) { var photoSize = (value.size/1000000) <= 2 ; var photoext = !(validPhoto(value.name)); if (!photoSize && !photoext) { $scope.showPPicFlag = false; angular.element('.helpmesspic').find('span')[0].style.color = "red"; angular.element('.helpmesspic').find('span')[1].style.color = "red"; angular.element('.uploadPhoto').prop('disabled', true); } else if (!photoSize) { $scope.showPPicFlag = false; angular.element('.helpmesspic').find('span')[0].style.color = "red"; angular.element('.uploadPhoto').prop('disabled', true); } else if ( !photoext) { $scope.showPPicFlag = false; angular.element('.helpmesspic').find('span')[1].style.color = "red"; angular.element('.uploadPhoto').prop('disabled', true); } else { $scope.showPPicFlag = true; angular.element('.uploadPhoto').prop('disabled', false); } } }, true);

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
;        
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
;