2015-06-03 23 views
1

我需要更新包含特定數字的XML節點。如果我在數字中進行硬編碼(參見圖1),我的查詢就可以工作,但我希望通過傳遞一個包含字符串(variableToBeReplaced)的變量來實現此動態。我現在寫了這個(見圖2),但它沒有正確讀取變量,因此沒有對xml進行任何更改。有誰知道我可以在updatexml()函數中包含變量嗎?PL/SQL:在UPDATEXML函數中使用變量

圖1

select updateXML(xmltype(xmlbod),'/LpnList/Lpn/LicensePlateNumber[text() = "12345"]','67890').getClobVal() doc 
from myTable 
where id = '1' 

圖2

select updateXML(xmltype(xmlbod), '/LpnList/Lpn/LicensePlateNumber[text()= '|| variableToBeReplaced || ']','67890').getClobVal() doc 
from myTable 
where id = '1' 

回答

0

我只是缺失 「」 周圍的變量。

select updateXML(xmltype(xmlbod), '/LpnList/Lpn/LicensePlateNumber[text()= "'|| variableToBeReplaced || '"]','67890').getClobVal() doc 
from myTable 
where id = '1'