[英]Get xmltype in field in Oracle column CLOB
我有一個包含xml格式的列CLOB類型。
我需要用一個簡單的查詢來獲取與此字段不同的所有類型:
防爆。 該字段包含不同的類型:
First record:
<Message type="New Address" xmlns="http://euroconsumers.org/ecommerce/2009/01/scope/messages"><Customer ...
Second record:
<Message type="Added Email" xmlns="http://euroconsumers.org/ecommerce/2009/01/scope/messages"><Customer ...
Third record:
<Message type="New Order" xmlns="http://euroconsumers.org/ecommerce/2009/01/scope/messages"><Customer ...
我想檢索:
New Address
Added Email
New Order
這適用於您的數據:
select xmlquery('/*/@type'
passing xmltype(<clob column>)
returning content)
from <your table>;
演示:
create table t42 (clob_col clob);
insert into t42 values ('<Message type="New Address" xmlns="..."><Customer type="x"></Customer></Message>');
insert into t42 values ('<Message type="Added Email" xmlns="..."><Customer></Customer></Message>');
insert into t42 values ('<Message type="New Order" xmlns="..."><Customer></Customer></Message>');
select xmlquery('/*/@type'
passing xmltype(t42.clob_col)
returning content)
from t42;
XMLQUERY('/*/@TYPE'PASSINGXMLTYPE(T42.CLOB_COL)RETURNINGCONTENT)
----------------------------------------------------------------
New Address
Added Email
New Order
或這個:
select xmltype(<clob_column>).extract('/*/@type')
from <your table>;
演示:
select xmltype(clob_col).extract('/*/@type')
from t42;
XMLTYPE(CLOB_COL).EXTRACT('/*/@TYPE')
-------------------------------------
New Address
Added Email
New Order
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.