Topic
  • 1 reply
  • Latest Post - ‏2012-03-01T20:45:48Z by MatthiasNicola
aitkenhead
aitkenhead
5 Posts

Pinned topic PureXML Cookbook XML UPDATE examples

‏2012-03-01T19:58:31Z |
I have been reading the PureXML cookbook avidly.

I am having trouble with several of the examples in Chapter 12 on updating XML using XMLQUERY. Many of the examples (Figure 12.8, 12.9, 12.10, etc.) do not show a PASSING .. AS .. clause in the XMLQUERY usage. Here is Figure 12.8

UPDATE customer
set info = XMLQUERY (' transform
copy $mycust := $INFO
modiffy do replace
value of $mycust/customerinfo/addr/street
with "43 WestCreek"
return $mycust')
where cid = 1002

Is this an error in the book? Why is it not necessary to declare $INFO by means of PASSING INFO AS "INFO" clause in the XMLQUERY?

When I tried an anology in my own database it woudn't work until I thew in the PASSING.. AS ... clause
Updated on 2012-03-01T20:45:48Z at 2012-03-01T20:45:48Z by MatthiasNicola
  • MatthiasNicola
    MatthiasNicola
    321 Posts

    Re: PureXML Cookbook XML UPDATE examples

    ‏2012-03-01T20:45:48Z  
    Hello,

    the answer to your question is in section 7.2.1 "Referencing XML Columns in SQL/XML functions" on page 162 of the DB2 pureXML Cookbook.

    In short, DB2 for Linux, UNIX, and Windows version 9.5 or higher allows you to reference columns directly as XQuery variables. Note that the variable name must be upper case, i.e. $INFO instead of $info.

    This is just a shortcut notation to simplify the syntax a little bit.

    You say that you tried an analogy in your own database but it didn't work. Which database were you using?

    Matthias


    Matthias Nicola
    http://www.tinyurl.com/pureXML
    http://nativexmldatabase.com/