oracle extractvalue连接另一个表中标记名的值
我有一个奇怪的场景,我有两个表,其中包含以下类型的数据oracle extractvalue连接另一个表中标记名的值,oracle,concat,xmltype,xmltable,extract-value,Oracle,Concat,Xmltype,Xmltable,Extract Value,我有一个奇怪的场景,我有两个表,其中包含以下类型的数据 table1: key1, xmldata1 1,<start><dat1>hi/dat1><dat2>hello</dat2>........</end> 2,<start><dat1>hihi/dat1><dat2>hellohello</dat2>.......</end> tab
table1:
key1, xmldata1
1,<start><dat1>hi/dat1><dat2>hello</dat2>........</end>
2,<start><dat1>hihi/dat1><dat2>hellohello</dat2>.......</end>
table2:
key1, fld1, name1
1, dat1, message1
2, dat1, message2
2, dat2, message3
这可能吗?表1 xmldata1中的dat1、dat2、dat3标记是动态的,可以有“n”个dat标记。是的,有可能
select T2.key1, T2.name1, xmlcast(T1.xmldata1.extract('/start/'||T2.fld1) as varchar2(4000)) as message
from table2 T2
join table1 T1
on T1.key1 = T2.key1
;
或
select T2.key1, T2.name1, xmlcast(T1.xmldata1.extract('/start/'||T2.fld1) as varchar2(4000)) as message
from table2 T2
join table1 T1
on T1.key1 = T2.key1
;
select T2.key1, T2.name1, extractvalue(T1.xmldata1, '/start/'||T2.fld1) as message
from table2 T2
join table1 T1
on T1.key1 = T2.key1
;