我有这个CLOB列,其中基本上包含假XML。我称之为假的,因为它不像普通的XML文档那样遵循相同的父子结构。
来自我的clob的样本:
<retryDetails>
<numberOfRetries>0</numberOfRetries>
<isToDoEntrySuppressed>false</isToDoEntrySuppressed>
</retryDetails>
<interimStatus>D1DS</interimStatus>
<completionDetail>
<updateStatusDateTime>2017-07-06-15.24.14</updateStatusDateTime>
<completionEventDataArea>false</completionEventDataArea>
<servicePointCompletionDetails>
<servicePointDataDetails/>
</servicePointCompletionDetails>
<messageCompletionInformation/>
<installDataDetails/>
<ctCheck>
<currentTransformerDetails/>
</ctCheck>
<vtCheck>
<voltageTransformerDetails/>
</vtCheck>
<existingDevice>
<deviceCompletionDetails>
<deviceDataDetails/>
<readingCompletionDetails>
<readingDetails/>
</readingCompletionDetails>
</deviceCompletionDetails>
<itemCompletionDetails>
<itemDataDetails/>
</itemCompletionDetails>
<meterTestDataDetails/>
<meterDataDetails/>
</existingDevice>
<newDevice>
<deviceCompletionDetails>
<deviceDataDetails/>
<readingCompletionDetails>
<readingDetails/>
</readingCompletionDetails>
</deviceCompletionDetails>
<itemCompletionDetails>
<itemDataDetails/>
</itemCompletionDetails>
<meterDataDetails/>
<currentTransformerDetails/>
<voltageTransformerDetails/>
</newDevice>
<completionInformation>
<customerContactDetails/>
<remarkTypes/>
<grantExtensionDetails/>
<paymentDetails/>
</completionInformation>
</completionDetail>
<responseDetail>
<message>
<taskId>01327329221115</taskId>
<hostExternalId>01327329221115</hostExternalId>
<taskType>D1-ServiceInvestigation</taskType>
<completionDateTime>2017-07-06-15.24.14</completionDateTime>
<completedByCrew>Successfully Issued a work to CREW=E04393</completedByCrew>
<messageId>01327329221115</messageId>
<completionInformation>
<dispatchDateTime>2017-07-06-15.24.14</dispatchDateTime>
<customerContactDetails/>
<remarkTypes/>
</completionInformation>
<utilityCompletionInformation>
<servicePointCompletionDetails>
<servicePointDataDetails>
<servicePointId>741788842119</servicePointId>
</servicePointDataDetails>
</servicePointCompletionDetails>
<existingDevice>
<meterCompletionDetails>
<verificationDetails>
<response>
<readingDetails/>
</response>
</verificationDetails>
<meterDataDetails/>
<readingCompletionDetails>
<readingDetails/>
</readingCompletionDetails>
</meterCompletionDetails>
<itemCompletionDetails>
<verificationDetails>
<response>
<readingDetails/>
</response>
</verificationDetails>
<itemDataDetails/>
</itemCompletionDetails>
</existingDevice>
<newDevice>
<meterCompletionDetails>
<verificationDetails>
<response>
<readingDetails/>
</response>
</verificationDetails>
<meterDataDetails/>
<readingCompletionDetails>
<readingDetails/>
</readingCompletionDetails>
</meterCompletionDetails>
<itemCompletionDetails>
<verificationDetails>
<response>
<readingDetails/>
</response>
</verificationDetails>
<itemDataDetails/>
</itemCompletionDetails>
</newDevice>
</utilityCompletionInformation>
</message>
<fault/>
</responseDetail>
我需要做的是弄清楚如何在select语句中拉出此数据混乱中的特定节点,特别是&#34; completedByCrew&#34; 节点。
我试过这个方法 -
SELECT XMLQUERY('/root/retryDetails/numberOfRetries/text()'
PASSING xmltype(to_clob('<root>') ||
A.BO_DATA_AREA ||
'</root>') RETURNING CONTENT) AS RESULT
FROM CISADM.D1_COMM_IN A
但是当我超过Retries节点数时,信息停止返回并且只是为空。有什么想法吗?
答案 0 :(得分:0)
我无法让你的例子工作,但我认为你可以在解析它之前将原始文本放在根元素(在这个例子中名为“root”),而Oracle的XML引擎会更快乐。 / p>
select XMLQUERY('/root/responseDetail/message/completedByCrew/text()'
PASSING xmltype( to_clob('<root>') || A.BO_DATA_AREA || '</root>' )
RETURNING CONTENT) AS RESULT
FROM CISADM.D1_COMM_IN A