我将以下XML存储在数据库中作为CLOB,我想从下面给出的数据中SELECT
hiPolicyYear标记的值。
<?xml version="1.0"?>
<boForm>
<boField>
<name>hiLeaveTypeDesc_1</name>
<value>Annual Leave</value>
</boField>
<boField>
<name>dpStartDate_1</name>
<value>20180108 000000</value>
</boField>
<boField>
<name>dpEndDate_1</name>
<value>20180121 000000</value>
</boField>
<boField>
<name>hiPolicyYear</name>
<value>2018</value>
</boField>
</boForm>
我尝试过以下sql:
SELECT --XMLTYPE(BUSOBJ_XML)
.extract('//boField//value//text()')
.getStringVal()
XMLTYPE(BUSOBJ_XML)
.extract('//boField//value//text()')
.getStringVal()
FROM business_object where busobj_id in ( 6854135, 6419639);
但是我在值字段中给出了XML中的所有值,我甚至尝试添加这样的where子句:
SELECT XMLTYPE(BUSOBJ_XML)
.extract('//boField//value//text()')
.getStringVal()
但是这给了来自business_object的null,其中busobj_id在(6854135,6419639) 和XMLTYPE(BUSOBJ_XML).extract(&#39; // boField // name // text()&#39;)。getStringVal()=&#39; hiPolicyYear&#39;;
答案 0 :(得分:0)
找到答案:
选择himastart,busobj_id from(select extractValue(xmltype(busobj_xml),&#39; / boForm / boField [name =&#34; hiMAStart&#34;] / value&#39;)作为himastart,busobj_id 来自business_object,其中himastart不为空的busobj_id(6854135,6419639);