1

I want to update an XML column in DB2 with dynamic values or you can say with values that I'll pick from another table and insert them in the xml column.

I know how to insert a node along with its value that we provide by hard coding it, e.g.

<data>some_value</data>

I want to do it in the following way:

UPDATE my_table SET my_table_column = XMLQuery(..... <data>???</data>)
WHERE my_table_id = other_table_id;

Where I place ??? I need a kind of select statement here which will come up with actual value for the node.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
Superman
  • 871
  • 2
  • 13
  • 31
  • I don't think you need `XMLQUERY()` for that. What "_kind of select statement_" have you tried, and what was the result? – mustaccio Feb 27 '14 at 13:25
  • Yes if I've to select the whole value of that column, then yes I don't need XMLQuery. I need XMLQuery only in the case when I have to traverse within that particular record's xml doc. ** 123 456 789 ** Now inside this doc we can have any kind of data with random system names. Now I just need to return only this part e.g **456** instead of whole xml doc, when criteria matched. – Superman Feb 27 '14 at 14:35
  • possible duplicate of [how to use if else in xquery assignment](http://stackoverflow.com/questions/3687218/how-to-use-if-else-in-xquery-assignment) – Paul Sweatte Jun 25 '14 at 06:24
  • @PaulSweatte Thanks Paul. These two are not relevant. I'm thankful to you for your concern. By the way I resolved that issue back at that time. I'll post my answer here as soon as possible. Thanks. – Superman Jul 04 '14 at 10:52

0 Answers0