Re: Modifying data in complex type

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Michael,

I thought I had already tried what you suggested, but I must have had the
syntax incorrect somewhere, or my predicates weren't correct, or something.
Either way, I just tried it as you suggested and it worked perfectly!

Thank you so much for your help, it was invaluable!

"Michael Rys [MSFT]" wrote:

> I think your problem with the insert is that you have not specified a single
> static node.
>
> Try something like:
>
> insert <Eyes><LeftEye>purple</LeftEye><RightEye>black</RightEye></Eyes>
> into (test:Face[yourpredicate])[1]
>
> Best regards
> Michael
>
> "h_e_kyle" <hekyle@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:E466ECFE-18A5-47FD-9095-D0FB4C962BDE@xxxxxxxxxxxxxxxx
> > Sorry I didn't mention that...I am using SQL Server 2005. I was originally
> > trying to modify the contents using just a 'replace value of' in a
> > modify()
> > method, which is what I realized I cannot do. It was rejected because I
> > was
> > trying to replace the value of a non-atomic type. This 'Face' node is one
> > node in a larger Xml Document stored in a SQL Server 2005 table of typed
> > Xml.
> >
> > I tried a delete and an insert, but (and perhaps I was doing it
> > incorrectly)
> > the insert did not work. The command I was using was like this:
> >
> > UPDATE Table1 SET XmlData.modify('declare namespace test="http://...";;
> > insert <Eyes><LeftEye>purple</LeftEye><RightEye>black</RightEye></Eyes>
> > into test:Face
> >
> > I also had a conditional statement to select the specific 'Face' to insert
> > into. Again, I received an error because I was trying to insert something
> > that was not a simple type.
> >
> > Would you be able to give me an example (or a link to an example, or even
> > the name of a book with an example would be great) of the first option you
> > presented (for updating the old tree with the new one)? I have seen
> > mention
> > made about the ability to do that, but I have not seen how to implement
> > it.
> >
> > Thank you so much for taking the time to respond, and Happy New Year!
> > Heather
> >
> > "Michael Rys [MSFT]" wrote:
> >
> >> Are you using SQL Server 2005 or 2000?
> >>
> >> In 2005, you can do:
> >>
> >> 1. Create a new instance with the new Eyes (using FOR XML and XQuery) and
> >> update the old tree with the new one.
> >>
> >> 2. Do a delete and an insert in two modify() methods.
> >>
> >> Best regards
> >> Michael
> >>
> >> "h_e_kyle" <hekyle@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:1E372518-91E9-4BEA-BB10-56C1AAEC7DDB@xxxxxxxxxxxxxxxx
> >> >I need to be able to modify the contents of a node such as this:
> >> > <Face>
> >> > <Eyes>
> >> > <LeftEye>blue</LeftEye>
> >> > <RightEye>brown</RightEye>
> >> > </Eyes>
> >> > </Face>
> >> >
> >> > Ideally I would like to do this by replacing the Face contents with a
> >> > completely new 'Eyes' node. Since SQL server does not allow for complex
> >> > types
> >> > in its update methods, I am wondering if anyone has any suggestions for
> >> > a
> >> > way
> >> > to work around this limitation?
> >> >
> >> > Thanks!
> >> >
> >>
> >>
> >>
>
>
>
.



Relevant Pages

  • Re: Abusers & AMF - Alt Med Fibromyalgia - See Internet Laws
    ... Recent Sent and there is a Tree version on Google groups. ... some who only knew you weren't posting as Michael Baugh. ... > dollar instead of just 57 cents. ...
    (alt.med.fibromyalgia)
  • Re: OT small disaster in our community
    ... >> Michael wrote: ... >>> had been cut by a huge branch that fell from a tree. ... The power company came and fixed ... > We live in the upper peninsula of Michigan. ...
    (alt.support.diabetes)
  • Re: Leylandii advice
    ... On 10/10/2011 15:14, michael wrote: ... afternoon.The tree is about 20m tall and growing rapidly.Our adjacent ... the tree have declined.. ... Should we join forces with our adjacent neighbour and approach them ...
    (uk.rec.gardening)
  • Re: Code Group Security policy deployment
    ... > Don't try to modify these files manually. ... >> Use of included script samples are subject to the terms specified at ...
    (microsoft.public.dotnet.security)
  • Re: Add perent element
    ... Seoul. ... >> Thanks Michael. ... >>> tree and use the FOR XML PATH mode to recompose the tree with the new ... >>> the subtrees involved in the updates and not the whole XML document. ...
    (microsoft.public.sqlserver.xml)