简体   繁体   English

从LOB内容中获取部分消息

[英]Get part of message from LOB content

I have some XML content(less than 2000 bytes) in a LOB (Large OBject) column. 我在LOB(大对象)列中有一些XML内容(少于2000个字节)。 I have used dbms_lob_substr(messagebody) to get the actual XML content but I need to get the exact value of a particular node. 我已经使用dbms_lob_substr(messagebody)来获取实际的XML内容,但是我需要获取特定节点的确切值。

eg. 例如。

<first name>xyz</first name>
<last name>abcd</last name>

I need the value of say <first name> . 我需要say <first name>的值。 How can I achieve this? 我该如何实现?

Your XML seems to be missing a root node? 您的XML似乎缺少根节点? If your XML data is as you show it, you can get XMLTable() function to parse it if you put it in a dummy root node, for example like this: 如果您的XML数据如您所显示,则可以将XMLTable()函数解析到虚拟根节点中,例如,如下所示:

select x.firstname
  from mytable,
  xmltable(
   '/rootnode'
   passing xmltype('<rootnode>'||myclobcol||'</rootnode>')
   columns
      firstname varchar2(100) path 'firstname'
  ) x

If you need to get multiple values at the same time, you just add to the columns clause: 如果需要同时获取多个值,只需将其添加到columns子句中:

select x.*
  from mytable,
  xmltable(
   '/rootnode'
   passing xmltype('<rootnode>'||myclobcol||'</rootnode>')
   columns
      firstname varchar2(100) path 'firstname',
      lastname  varchar2(100) path 'lastname',
      middleini varchar2(10)  path 'middleinitial'
  ) x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM