MySQL UpdateXML with automatic node inserting?
Posted
by JimPsr
on Stack Overflow
See other posts from Stack Overflow
or by JimPsr
Published on 2010-04-12T12:17:32Z
Indexed on
2010/04/12
12:23 UTC
Read the original article
Hit count: 185
I am writing an application that supports custom fields. Currently I store all custom fields in a XML formated text field ( e.g. '<root><field1>val1</field1><field2>val2</field2></root>'
in cust_field)
I am able to to use updateXML(cust_field, '/root/field1', '<field1>new value</field1'
) to update those values, however if I use updateXML(cust_field, '/root/field3', '<field3>new value</field3>'
) then it does not work since field3 is not in the old value. Is there a way to let MySQL automatically insert the new field3 node and its value into cust_field? I am thinking about stored procedure or even stored function but not familiar with both, can anyone point me to the right direction?
© Stack Overflow or respective owner