Help understanding FLWOR modify statement
-
Here is what my XML document looks like. <DATAMATRIX> <FSDATAMATRIX> <DM_OBJECT_TYPE>ITEM0</DM_OBJECT_TYPE> <FIELD1>BELGIUM</FIELD1> <FIELD2>BEVERAGES, NON-ALCOHOLIC</FIELD2> <FIELD4>NO</FIELD4> <FIELD5>YES</FIELD5> </FSDATAMATRIX> <FSDATAMATRIX> <DM_OBJECT_TYPE>ITEM0</DM_OBJECT_TYPE> <FIELD1>BRAZIL</FIELD1> <FIELD2>CHEESE</FIELD2> <FIELD4>NO</FIELD4> <FIELD5>YES</FIELD5> </FSDATAMATRIX> </DATAMATRIX> Using the following code snipet, I got the XMLDOC variable to update, but it will only update the field that previously had a value of "BELGIUM" to the value in my variable, @XMAXPPM. SET @XMLDOC.modify(' replace value of (/DATAMATRIX/FSDATAMATRIX/FIELD1[.="BELGIUM"]/text())[1] with sql:variable("@XMAXPPM") ') How do I write a modify statement that will update FIELD2 to a value only when FIELD1 is "BELGIUM" ? Thanks, David
-
Here is what my XML document looks like. <DATAMATRIX> <FSDATAMATRIX> <DM_OBJECT_TYPE>ITEM0</DM_OBJECT_TYPE> <FIELD1>BELGIUM</FIELD1> <FIELD2>BEVERAGES, NON-ALCOHOLIC</FIELD2> <FIELD4>NO</FIELD4> <FIELD5>YES</FIELD5> </FSDATAMATRIX> <FSDATAMATRIX> <DM_OBJECT_TYPE>ITEM0</DM_OBJECT_TYPE> <FIELD1>BRAZIL</FIELD1> <FIELD2>CHEESE</FIELD2> <FIELD4>NO</FIELD4> <FIELD5>YES</FIELD5> </FSDATAMATRIX> </DATAMATRIX> Using the following code snipet, I got the XMLDOC variable to update, but it will only update the field that previously had a value of "BELGIUM" to the value in my variable, @XMAXPPM. SET @XMLDOC.modify(' replace value of (/DATAMATRIX/FSDATAMATRIX/FIELD1[.="BELGIUM"]/text())[1] with sql:variable("@XMAXPPM") ') How do I write a modify statement that will update FIELD2 to a value only when FIELD1 is "BELGIUM" ? Thanks, David
SET @XMLDOC.modify('
replace value of (/DATAMATRIX/FSDATAMATRIX/FIELD2[../FIELD1="BELGIUM"]
/text())[1]
with sql:variable("@XMAXPPM")
')Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
-
SET @XMLDOC.modify('
replace value of (/DATAMATRIX/FSDATAMATRIX/FIELD2[../FIELD1="BELGIUM"]
/text())[1]
with sql:variable("@XMAXPPM")
')Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
Perfect. I got my project almost complete. Your assistance is greatly appreciated. :-D