为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8
【操作系统】:win10
【CPU】:
【问题描述】*:要实现的效果是:把FileNames中的数据按逗号隔开查询为多行数据。
select id, AreaCode, state, FileTypes,
ExtractValue(column_value, '/v') AS FileName
from (
SELECT id, AreaCode, state, FileTypes,
XMLType('<root><v>' || REPLACE(FileNames, ',', '</v><v>') || '</v></root>') AS file_xml
FROM (
SELECT *from a_test
UNPIVOT
(
FileNames FOR FileTypes IN
(ProductPicSrc,SpreadCertSrc,SpreadCertRptSrc,InspectRptSrc,PlateSrc,ProductQualifiedSrc,PracticabilitySrc,verificationSrc)
) P
WHERE state=8
) as a
ORDER BY id asc
) as b
CROSS JOIN XMLTable('/root/v' PASSING file_xml COLUMNS column_value XMLTYPE PATH 'v' ) AS x
--where column_value is not NULL
在形成xml时候是正确的,但是在CROSS JOIN XMLTable 之后就不对了,查询到的fileName都是null值
如果加上条件where column_value is not NULL 后就查不出来了;
已解决