更新 oracle 中的 xml 个表(用例 - 刷新后屏蔽敏感数据)

updating xml tables in oracle (use case - masking sensitive data after refresh )

我正在尝试更新 oracle 中的 xml 列并遇到我无法解决的错误。这里需要一些帮助

如果数据存在并且 "USA" 则只更新值或什么也不做

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

我没有正确理解这两个条件 (fn:exists(/row/c178[@m=83])) 和 $t/row/c178[@m=82]="USA"

这个单一条件工作正常 --> (fn:exists(/row/c178[@m=83])) 因为我将它用于其他一些表但是当我们添加第二个条件时一切都乱了向上 --> $t/row/c178[@m=82]="USA"

更新 USER.TABLE t1

设置t1.xmlrecord=

XMLQuery('

复制 $t := .修改(

if fn:exists /row/c2 then replace the value of node $t/row/c2 with concat("firstname",$t/row/@id) else() ,

if fn:exists /row/c3 then replace the value of node $t/row/c3 with concat("lastname",$t/row/@id) else( ),

if ((fn:exists (/row/c178[@m=83])) 和 ($t/row/c178[@m =82]="USA ")) 然后用 ("NEY YORK") else( ),

if ((fn:exists (/row/c4)) and ($t/row/c178[@m=82]="USA ")) 然后替换节点的值$t/row/c4 与 ("Manhattan ") else() ,

if ((fn:exists (/row/c5)) and ($t/row/c178[@m=82]="USA ")) 然后替换节点的值$t/row/c5 与 concat("NY 10036, USA. ",$t/row/@id) else()

)

return$t

'

及格t1.xmlrecord

return内容

);