2010-02-19 66 views

回答

1

你可以用任何appendChildXml()insertChildXml(),或insertXmlBefore()刪除現有的節點,然後將其與現在包含在新的屬性重新加回一起使用的deleteXml()的組合。

1
with t as (
    select 
     xmltype('<a><b c="2">1</b></a>') x, 
     '/a/b' node, --node where attribute located 
     '@d' att,  --attribute name 
     'new' val  --new value 
    from dual 
) 
select 
    x, 
    insertchildxml(deletexml(x,node||'/'||att), node, att, val) x_new 
from t 
+0

的作品就像一個魅力! – Cyryl1972 2016-09-14 08:19:55

1

簡單的Oracle SQL添加 「attrname = attrval」 在clobcol列所有XML元素MYNODE每行中MYTABLE

update mytable s set 
    s.clobcol = insertchildxml(xmltype(s.clobcol) 
          ,'//mynode' 
          ,'@attrname' 
          ,'attrval' 
          ).getclobval(); 
相關問題