SQL Oracle如何在Blob列中提取XML标签内容
有一个XML在类型Blob(In Oracle)中,我需要从该XML访问某个标签。在此之前,我可以以这种方式检索列:
SELECT TRIM(UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(my_column_blob, 1024))) as tag_name_xml
FROM my_table
我如何返回CUF或CCT标签的值/内容? 我希望有更多知识的人的帮助。
提出的解决方案非常优雅,但是就我而言,使用此XML结构访问CUF标签的内容会是什么样?
<?xml version="1.0" encoding="UTF-8"?>
<cteProc xmlns="http://www.example.com" version="3.00">
<CTe>
<infCte version="3.00">
<ide>
<cUF>15</cUF>
</ide>
</infCte>
</CTe>
</cteProc>
There is an xml that is in a column of type BLOB (in oracle) and I need to access a certain tag from that xml. Until then I can retrieve the column this way:
SELECT TRIM(UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(my_column_blob, 1024))) as tag_name_xml
FROM my_table
Here I leave part of the xml content:
How do I return the value/content of the cUF or cCT tag?
I would like the help of people with more knowledge, please.
the proposed solutions are very elegant, but for my case what would it be like to access with this xml structure to access the contents of the cUF tag?
<?xml version="1.0" encoding="UTF-8"?>
<cteProc xmlns="http://www.example.com" version="3.00">
<CTe>
<infCte version="3.00">
<ide>
<cUF>15</cUF>
</ide>
</infCte>
</CTe>
</cteProc>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
xmltype
和xmltable
:或
xmlquery
:对于示例数据:
两者都输出:输出:
db&lt;&gt; fiddle
Use
XMLTYPE
andXMLTABLE
:Or
XMLQUERY
:Which, for the sample data:
Both output:
db<>fiddle here
您可以首先将BLOB数据转换为CLOB类型,然后提取所需的标签。希望以下两个功能可以解决您的问题:
您可以这样使用它:
我使用第二个功能get_soap_partclob()从某些Web服务的SOAP信封响应中获取一些很大的B64数据。这就是为什么返回类型是clob的原因。您可以将返回的值投放到其他方面,也可以对功能进行自己的调整。
You can first convert your BLOB data into CLOB type, and then extract the tags you need. Here are two functions that will, hopefully, solve your problem:
You can use it like this:
I use the second function Get_SOAP_PartCLOB() to get some pretty big B64 data out of the soap envelope response from certain web services. That's why the return type is CLOB. You can cast the returned value to something else or make your own adjustments to the function.