Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using XQUERY/Modify to replace a piece of my XML with value from varchar field

I have a table:

MyTable
  config as XML
  title as varchar(255)

In MyTable.config I have XML in the following structure:

<configuration pagetitle="myConfig">
  <column>
    <row>
      <component id="1" type="MyPiece" title="My Title" text="junk" />
    </row>
  </column>
</configuration>

I need a script to inject the value of MyTable.text into the text attribute of the component node in my config XML.

I know this is wrong, but I want to do something similar:

UPDATE MyTable SET config.configuration.column.row.component.title = title
like image 222
Jason Avatar asked Nov 09 '08 15:11

Jason


1 Answers

UPDATE MyTable
   SET Config.modify('
   replace value of (/configuration/column/row/component/@title)[1]
    with sql:column("title")
   ')
like image 60
Jason Avatar answered Oct 29 '22 19:10

Jason