【发布时间】:2017-12-08 14:50:28
【问题描述】:
我在 Oracle 12c 数据库的“数据”表的“属性”列中有以下数据:
<Attributes>
<Map>
<entry key="accountFlags">
<value>
<List>
<String>Normal User Account</String>
</List>
</value>
</entry>
<entry key="cn" value="paul.john"/>
<entry key="department" value="IT"/>
<entry key="description" value="New account. Automatically created"/>
<entry key="displayName" value="John, Paul"/>
<entry key="distinguishedName" value="CN=paul.john,OU=Users,DC=test,DC=com"/>
<entry key="givenName" value="Paul"/>
<entry key="homeMDB" value="CN=Test,CN=Databases,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=test,DC=com"/>
<entry key="l" value="London"/>
<entry key="mail" value="paul.john@test.com"/>
<entry key="mailNickname" value="PaulJ"/>
<entry key="manager" value="CN=brock.lesnar,OU=Users,DC=test,DC=com"/>
<entry key="memberOf">
<value>
<List>
<String>CN=Test1,OU=Rights,OU=Groups,DC=test,DC=com</String>
<String>CN=Test2,OU=Rights,OU=Groups,DC=test,DC=com</String>
<String>CN=Test3,OU=Rights,OU=Groups,DC=test,DC=com</String>
<String>CN=Test4,OU=Rights,OU=Groups,DC=test,DC=com</String>
</List>
</value>
</entry>
</Map>
</Attributes>
我希望从该列中提取“memberOf”的值,如下所示:
MEMBER_OF
---------
CN=Test1,OU=Rights,OU=Groups,DC=test,DC=com
CN=Test2,OU=Rights,OU=Groups,DC=test,DC=com
CN=Test3,OU=Rights,OU=Groups,DC=test,DC=com
CN=Test4,OU=Rights,OU=Groups,DC=test,DC=com
我已尝试使用以下返回 null 的查询:
SELECT EXTRACTVALUE(xmltype(attributes), '/Attributes/Map/entry[@key="memberOf"]/value/List/@String')
FROM DATA;
我也试过下面的查询,它也返回 null
SELECT EXTRACTVALUE(xmltype(attributes), '/Attributes/Map/entry[@key="memberOf"]/value[1]/List/@String')
FROM DATA;
不确定是否需要在查询中传递其他内容?
【问题讨论】: