我在列TEST1(表名:TableTest)中有数据,如
<n0:RouterName Value="ST_APOP"/>
<n0:ExtZone/>
<n0:SalesOrders>
<n0:SalesOrder ValidationResult="SUCCESS">
<n0:SalesOrderID Value="4F47N006800000_0261"/>
我需要在我的选择查询中选择4F47N006800000_0261值。如何修剪它。
答案 0 :(得分:0)
您的XML无效 - 因此,我们添加结束标记:
CREATE TABLE your_table ( xml ) AS
SELECT '<n0:RouterName Value="ST_APOP"/>
<n0:ExtZone/>
<n0:SalesOrders>
<n0:SalesOrder ValidationResult="SUCCESS">
<n0:SalesOrderID Value="4F47N006800000_0261"/>
</n0:SalesOrder>
</n0:SalesOrders>' FROM DUAL
<强>查询强>:
SELECT SalesOrderId
FROM your_table t,
XMLTABLE(
XMLNAMESPACES( 'http://your.server/namespaces/n0' AS "n0" ),
'//root/n0:SalesOrders/n0:SalesOrder'
PASSING XMLTYPE(
'<root xmlns:n0="http://your.server/namespaces/n0">'
|| t.xml
|| '</root>
)
COLUMNS SalesOrderId VARCHAR2(100) PATH '//n0:SalesOrderID/@Value'
);
<强>输出强>:
SALESORDERID
-------------------
4F47N006800000_0261
答案 1 :(得分:-2)
select
substr(column_name,instr(column_name,'Value',1,2)+7,length(substr(column_name,instr(column_name,'Value',1,2)+7))-3)
from
test1