[英]updating xml tables in oracle (use case - masking sensitive data after refresh )
i am trying to update xml column in oracle and getting errors which i am not able to resolve . 我试图更新oracle中的xml列,并得到我无法解决的错误。 need some help here 需要一些帮助
if the data exists there and if its "USA" then only update the value or do nothing 如果数据存在,并且其“美国”,则仅更新值或不执行任何操作
update USER.TABLE t1
set t1.xmlrecord=
XMLQuery('
copy $t := . modify (
if(fn:exists(/row/c2)) then replace value of node $t/row/c2 with concat("firstname",$t/row/@id) else(),
if(fn:exists(/row/c3)) then replace value of node $t/row/c3 with concat("lastname",$t/row/@id) else(),
if (fn:exists(/row/c178[@m=83])) and $t/row/c178[@m=82]="USA" then replace value of node $t/row/c178[@m=83] with ("NEW YORK") else(),
if(fn:exists(/row/c4)) and $t/row/c178[@m=82]="USA" then replace value of node $t/row/c4 with ("Manhattan") else(),
if(fn:exists(/row/c5)) and $t/row/c178[@m=82]="USA" then replace value of node $t/row/c5 with concat(" NY 10036, USA.",$t/row/@id) else()
)
return $t
'
passing t1.xmlrecord
returning content
);
ORA-19114: XPST0003 - error during parsing the XQuery expression:
LPX-00801: XQuery syntax error at 'and'
5 if
(fn:exists(/row/c178[@m=83])) and $t/row/c178[@m=82]="USA" then replace
- ^
ORA-06512: at line 6
i am not getting these 2 conditions correct (fn:exists(/row/c178[@m=83])) and $t/row/c178[@m=82]="USA" 我没有使这两个条件正确(fn:exists(/ row / c178 [@ m = 83]))和$ t / row / c178 [@ m = 82] =“ USA”
this single condition is working fine --> (fn:exists(/row/c178[@m=83])) as i used it for some other tables but when we add this second condition everything is messed up --> $t/row/c178[@m=82]="USA" 这个单一条件工作正常->(fn:exists(/ row / c178 [@ m = 83]))就像我在其他表中使用它一样,但是当我们添加第二个条件时,一切都搞砸了-> $ t /行/ C178 [@米= 82] = “USA”
update USER.TABLE t1 更新USER.TABLE t1
set t1.xmlrecord= 设置t1.xmlrecord =
XMLQuery(' 的XMLQuery(”
copy $t := . 复制$ t:=。 modify ( 修改(
if fn:exists /row/c2 then replace value of node $t/row/c2 with concat("firstname",$t/row/@id) else(), 如果fn:exists / row / c2然后将节点$ t / row / c2的值替换为concat(“ firstname”,$ t / row / @ id)else(),
if fn:exists /row/c3 then replace value of node $t/row/c3 with concat("lastname",$t/row/@id) else(), 如果fn:exists / row / c3然后将节点$ t / row / c3的值替换为concat(“ lastname”,$ t / row / @ id)else(),
if ((fn:exists (/row/c178[@m=83])) and ($t/row/c178[@m=82]="USA ")) then replace value of node $t/row/c178[@m=83] with ("NEY YORK") else() , if ((fn:exists(/ row / c178 [@ m = 83]))和($ t / row / c178 [@ m = 82] =“ USA”))然后替换节点$ t / row / c178的值[@ m = 83]与(“ NEY YORK”)else()一起使用,
if ((fn:exists (/row/c4)) and ($t/row/c178[@m=82]="USA ")) then replace value of node $t/row/c4 with ("Manhattan ") else() , if((fn:exists(/ row / c4))和($ t / row / c178 [@ m = 82] =“ USA”))然后将节点$ t / row / c4的值替换为(“ Manhattan”) else(),
if ((fn:exists (/row/c5)) and ($t/row/c178[@m=82]="USA ")) then replace value of node $t/row/c5 with concat("NY 10036, USA. ",$t/row/@id) else() if((fn:exists(/ row / c5))和($ t / row / c178 [@ m = 82] =“ USA”))然后将节点$ t / row / c5的值替换为concat(“ NY 10036 ,美国。”,$ t / row / @ id)else()
) )
return $t 返回$ t
' “
passing t1.xmlrecord 传递t1.xmlrecord
returning content 返回内容
); );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.