I have a table with an XMLType field. The table is created and loaded using the following DDL / DML:
CREATE TABLE T_ECO_test_LOG
(
SECID NUMBER NOT NULL,
LOG_ATTRIBUTES SYS.XMLTYPE
)
INSERT INTO t_eco_test_log VALUES
( 1, XMLType(
'<attributes>
<attribute>
<name>remoteAddress</name>
<value>180.201.106.130</value>
</attribute>
<attribute>
<name>domain</name>
<value>BSI_US</value>
</attribute>
</attributes>'));
INSERT INTO t_eco_test_log VALUES
( 2, XMLType(
'<attributes>
<attribute>
<name>user</name>
<value>xxxx</value>
</attribute>
<attribute>
<name>domain</name>
<value>BSI_US</value>
</attribute>
</attributes>'));
I want to get different values in / attributes / attribute / name, in strings; Thus, with O data, I would like to get:
remoteAddress
domain
user
So far I have tried the following query:
select extractValue(value(x),'/attributes/attribute/name')
from t_eco_log,
table(xmlsequence(extract(log_attributes,'/attributes')) )x
But I get the following message:
ORA-19025: EXTRACTVALUE returns the value of only one node
If i use
select extract(value(x),'/attributes/attribute/name')
from t_eco_log,
table(xmlsequence(extract(log_attributes,'/attributes')) )x
I got an XML result that contains:
<name>remoteAddress</name><name>domain</name>
But I would like to get them as strings, how can I do this?
TIA