【发布时间】:2019-09-15 20:51:42
【问题描述】:
我将以下 XML 作为数据存储在表中的 1 列中。我想提取 VestingInfo 下的所有数据,每个源数据应该是一列。我尝试了以下方法,但它给出了无效的标识符错误
选择计划。* from cth01.tablename pl, XMLTABLE(XMLNAMESPACES ('http://...' 作为 "ns3", 'http:/...' 作为 "ns4"), '/CTHClob/ns3:OtherData/ns4:Participant/ns4:Plans' PASSING
xmltype(pl.rqst_info) COLUMNSNumber varchar2(20) 路径 'ns4:Number', Pin varchar2(20) path 'ns4:Pin') 计划在哪里 pl.prty_rqst_id = '';
XML 如下所示
<?xml version="1.0"?><CTHClobType xmlns:ns2="http://... xmlns:ns4....>
--namespaces removed
<ns3:OtherData>
<ns4:Participant>
<ns4:Name>ALEXA MAKAILA JAVAVILLAGE</ns4:Name>
<ns4:PIN>4159505</ns4:PIN>
<ns4:PlanBalance>3497.15</ns4:PlanBalance>
<ns4:ForcedDistributionAmount>3497.15</ns4:ForcedDistributionAmount>
<ns4:ParticipantListType>Critical</ns4:ParticipantListType>
<ns4:Plans>
<ns4:Plan>
<ns4:Number>100178</ns4:Number>
<ns4:Name>CHILDRENS HOSPITAL OF PHIL. RETIREMENT SAVINGS PLAN - CSA</ns4:Name>
<ns4:Balance>3497.15</ns4:Balance>
<ns4:VestingInfo>
<ns4:DelayedVestingLite>false</ns4:DelayedVestingLite>
<ns4:DelayedVestingFull>true</ns4:DelayedVestingFull>
<ns4:VestingSourcesOnSingleSchedule>false</ns4:VestingSourcesOnSingleSchedule>
--The above 3 should be repeted for each source
<ns4:Sources>
<ns4:Source>
<ns4:SourceID>T</ns4:SourceID>
<ns4:SourceName>EMPLOYER MATCH</ns4:SourceName>
<ns4:VestedPercentage>50</ns4:VestedPercentage>
<ns4:VestedAmount>5647.94</ns4:VestedAmount>
<ns4:UnAdjustedVestedPercent>50</ns4:UnAdjustedVestedPercent>
<ns4:TIAAContractNumber>330292F5</ns4:TIAAContractNumber>
<ns4:CREFContractNumber>430292F3</ns4:CREFContractNumber>
<ns4:ContractName>GRA</ns4:ContractName>
</ns4:Source>
<ns4:Source>
...
</ns4:Source>
</ns4:Sources>
</ns4:VestingInfo>
上面的 xml 是部分的,因为它完全是一个大的,所以删除了不相关的标签。
生成的元素应如下所示
【问题讨论】:
标签: sql xml extract-value