I want replace one value with another in XML value. What i need is to use a substring method:
UPDATE zamowienia_xml
SET tresc_xml.modify('
replace value of (/zamowienie/profil_rabatowy/rabat/text())[1]
with
(
if (1=1)
then
text(
substring(
"abcd",
1,
2)
)
)
else
text("0")
)');
I simplify the sql, it is not making what it should, but it still has the same error. Why this doesn’t work?
The error is:
[S0001][9303] Line 9: XQuery [zamowienia_xml.tresc_xml.modify()]: Syntax error near 'substring', expected ')'.
If someone what to see full sql, here can check:
UPDATE zamowienia_xml
SET tresc_xml.modify('
replace value of (/zamowienie/profil_rabatowy/rabat/text())[1]
with
(
if (substring(
(/zamowienie/profil_rabatowy/rabat/text())[1],
string-length((/zamowienie/profil_rabatowy/rabat/text())[1]), 1) = "%"
)
then
text(
substring(
string((/zamowienie/profil_rabatowy/rabat/text())[1]),
1,
string-length((/zamowienie/profil_rabatowy/rabat/text())[1]) - 1
)
)
else
(/zamowienie/profil_rabatowy/rabat/text())[1]
)');
Error is the same:
[S0001][9303] Line 12: XQuery [zamowienia_xml.tresc_xml.modify()]: Syntax error near 'substring', expected ')'.
I feel like i tried everything, but problem still exist.
And about the sql, what I want to achieve is to remove optional character “%” at the end.