Topic
  • 3 replies
  • Latest Post - ‏2011-12-12T18:13:46Z by MatthiasNicola
VV4H_mario_fernandes
43 Posts

Pinned topic update a xml column

‏2011-12-12T16:44:46Z |
Hi

Can you please let me know an sql that will update a xml column
I am using db2 9.7 on Linux
The table contains a single XML column.

The tag I want to replace or create is <sendingProcessName>.
If it exists I want to replace its value
If it doesnt exist I want to create it

Is there a single xpath query that does this?
<kasperSchema>
<TDSClient>
<VenomJmsMessage>
<sendingProcessName>
BATCH
<sendingProcessName>
</VenomJmsMessage>
</TDSClient>
</kasperSchema>
Updated on 2011-12-12T18:13:46Z at 2011-12-12T18:13:46Z by MatthiasNicola
  • VV4H_mario_fernandes
    43 Posts

    Re: update a xml column

    ‏2011-12-12T17:33:56Z  
    I have been able to get the answer for this myself.

    I first have to do an update and then a delete
  • VV4H_mario_fernandes
    43 Posts

    Re: update a xml column

    ‏2011-12-12T17:36:01Z  
    I have been able to get the answer for this myself.

    I first have to do an update and then a delete
    I have been able to get the answer for this myself.

    I first have to do a delete and then insert.

    Please see this thread for delete details

    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14496181&#14496181
    Please see here for insert

    http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.xml.doc%2Fdoc%2Fc0023490.html
  • MatthiasNicola
    MatthiasNicola
    322 Posts

    Re: update a xml column

    ‏2011-12-12T18:13:46Z  
    I have been able to get the answer for this myself.

    I first have to do a delete and then insert.

    Please see this thread for delete details

    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14496181&#14496181
    Please see here for insert

    http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.xml.doc%2Fdoc%2Fc0023490.html
    I would also recommend this article:

    Updating XML in DB2
    http://www.ibm.com/developerworks/data/library/techarticle/dm-0710nicola/
    Note that you can not only delete and insert elements. You can also replace elements, replace their values, and rename them. And the same for attributes.

    Good luck!


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