我们正面临DB2 SQL的问题。我们正试图检查我们是否可以找到解决方案。
问题陈述:
<RFPData>
是根节点。<RFPData>
.
.
.
.
<class dataStr="list">
.
.
.
</class >
<class dataStr="list">
<classCheckedProductStr>Life &lt;br/&gt;Dental &lt;br/&gt;</classCheckedProductStr>
<classDescriptionOptionText>All Active Full-Time Assistant Vice Presidents</classDescriptionOptionText>
<classDescriptionOption>5</classDescriptionOption>
<life>
<ClsLifePayPeriod>W</ClsLifePayPeriod>
<coverage dataStr="list">
<status>ACTIVE</status>
<coverageId>50</coverageId>
<coverageName>Buy Up Life with AD&D</coverageName>
<ClassLifeBasicLifeEmployee>22</ClassLifeBasicLifeEmployee>
<covId>50</covId>
<ClassLifeBasicLifeDependents>34</ClassLifeBasicLifeDependents>
<isCoverageSelected>Y</isCoverageSelected>
<SQ>0</SQ>
</coverage>
<coverage dataStr="list">
<status>ACTIVE</status>
<coverageId>54</coverageId>
<coverageName>Buy Up Dependent Life with AD&D</coverageName>
<ClassLifeBasicLifeEmployee>44</ClassLifeBasicLifeEmployee>
<covId>54</covId>
<ClassLifeBasicLifeDependents>43</ClassLifeBasicLifeDependents>
<isCoverageSelected>Y</isCoverageSelected>
<SQ>1</SQ>
</coverage>
<clsFutureEmpWaitingPeriodRule>1STFLWP</clsFutureEmpWaitingPeriodRule>
<clsCurrentEmpWaitingPeriodRule>1STFLWP</clsCurrentEmpWaitingPeriodRule>
<status>ACTIVE</status>
<clsCurrentEmpAveragedOver>-1</clsCurrentEmpAveragedOver>
<isCoverageChecked>Y</isCoverageChecked>
<clsCurrentEmpEarningsDefinition>-1</clsCurrentEmpEarningsDefinition>
<clsFutureEmpWaitingPeriodUnit>DY</clsFutureEmpWaitingPeriodUnit>
<ClsCurrentEmpLifeWaitingPeriodValue>14</ClsCurrentEmpLifeWaitingPeriodValue>
<clsCurrentEmpWaitingPeriodUnit>DY</clsCurrentEmpWaitingPeriodUnit>
<ClsLifeHoursWorked>12</ClsLifeHoursWorked>
<ClsFutureEmpLifeWaitingPeriodValue>33</ClsFutureEmpLifeWaitingPeriodValue>
</life>
<SQ>0</SQ>
</class>
<class dataStr="list">
.
.
.
</class >
.
.
.
.
</RFPData>
<classDescriptionOption>
节点值为“所有有效的全职主管”,则上面蓝色突出显示的<classDescriptionOptionText>
节点需要更新为值6。<class dataStr="list">
可能存在多个<classDescriptionOption>
。<classDescriptionOptionText>
值等同为“所有活动的全职监督员”。 / LI>
醇>
使用的更新脚本如下。
UPDATE T_SL_APP
SET SL_XML_TXT = XMLQUERY('
copy $new := $SL_XML_TXT
modify (
for $i in $new/RFPData/classSetup/class/classDescriptionOption return
do replace value of $i with "6"
)
return $new')
WHERE SL_APP_ID = '1184'
and xmlexists('$SL_XML_TXT//RFPData/classSetup/class[classDescriptionOptionText = "All Active Full-Time Supervisors"]');
有人可以帮我们解决。附上XML的整个结构以供参考。
答案 0 :(得分:1)
未经过测试,但尝试在XQuery中使用谓词:
copy $new := $SL_XML_TXT
modify (
for $i in $new/RFPData/classSetup/class[classDescriptionOptionText = "All Active Full-Time Supervisors"]/classDescriptionOption
return
do replace value of $i with "6"
)
return $new
上面只会迭代那些与Supervisor一起使用OptionText的“类”节点,访问Option并更新它。