?
Solved

Create Xml string and update table column using stored proc

Posted on 2008-10-30
2
Medium Priority
?
731 Views
Last Modified: 2013-11-18
I have the following string stored in my database column called TreeXml.


<C filename="00013024228c4e24a79bae959588acd4" parents="9daf7c70ac37479b8f91ef7bd08e07e6" DateModified="1217355187" taxonomyId="6aa742c4edff43a798c9067a2a4e223c" typeId="514044723" typeName="Answer" title="No" description=""><Conclusion /><Ps><P name="Approved" value="true" /><P name="Global or Country" value="Global" /><P name="Display on Questionaire" value="EA" /><P name="SL/SSL Owner /Maintained" value="02" /><P name="Sort Key" value="125" /><P name="Unique Number" value="963478" /></Ps></C>


I need to update this string
to add a new attribute called "Modified" in the  <C ...so the new string sould be

<C filename="00013024228c4e24a79bae959588acd4" parents="9daf7c70ac37479b8f91ef7bd08e07e6" DateModified="1217355187" taxonomyId="6aa742c4edff43a798c9067a2a4e223c" typeId="514044723" typeName="Answer" title="No" description=""  Modified="xyz ">


i am getting this xyz value using this

Select top (1)  C.UserName as LastModifiedBy
      from      QMSDocuments D
                  join QMSTaxonomyNames T on D.TaxonomyID = T.TaxonomyID
                  join QMSChanges C on C.Rowid = D.Rowid
      where      DocumentID = '00013024228c4e24a79bae959588acd4' order by C.ChangeDate desc



How do i achieve all this  in a stored proc
0
Comment
Question by:angireddy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 2000 total points
ID: 22893903
Well the way to do this properly is to create an XML DOM and using the LoadXML() method to load the string you have read from the database into it.

You now need to select the "C" node like

    cNode = xmldom.selectSingleNode('/C');

and then create a new attribute node with

   attrNode = xmldom.CreateAttribute('Modified');

and then set it's value :-

    attrNode.Value = today();  // or whatever

now add the new attribute to the attribute of the C node

    cNode.attributes.setNamedItem(attrNode);

and then save the document into a string

    str = xmldom.xml

and then write the string back into the database.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question