Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Xquery issue attempting to update an attribute


Xquery issue attempting to update an attribute

Author
Message
David Ladd-458242
David Ladd-458242
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 20
I am attempting to perform an update to an xml column (AttributeList). What my update needs to do is add a leading character (3) to an already existing string (Account_number_1). My code is as follows:

UPDATE tbl1
SET accountNumber = '3' + accountNumber,
AttributeList.modify
('replace value of (/AttributeList/Account_number_1/text())[1] with xs:text("3" + Account_number_1)')
WHERE ClientAccountId = @ClientAccountId

When I attempt to execute the query I receive the following error:

Msg 2214, Level 16, State 1, Procedure ModifyAcctNum, Line 28
XQuery [tbl1.AttributeList.modify()]: The type 'text' is not an atomic type

Can someone please help me with this as I am new to the xquery world and would greatly aapreciate the assistance.

Thank You!
David Ladd-458242
David Ladd-458242
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 20
For those of you who might need some kind of help regarding this issue in the future, here is the solution we managed to figure out:

UPDATE tbl1
SET accountNumber = '3' + accountNumber,
AttributeList.modify('replace value of (/AttributeList/CustodianRawData/dbo.tblAcct/Account_number_1/text())[1] with concat("3", string((/AttributeList/CustodianRawData/dbo.tblAccount_Registration_Data_Detail/Account_number_1)[1]))')
WHERE somelogic
AND somemorelogic

It was a matter of including a full path and a syntax correction in the concatenation.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search