Tuesday, October 09, 2007

SQL Query to select/update text from XML columns

Here's how to get data:

select * FROM
table_with_xml w
WHERE
w.XMLCOLUMN.EXTRACT('/xpath/goes/here/text()').getstringval() = 'test';

And how to update:

UPDATE TABLE_WITH_XML
SET XMLCOLUMN = UPDATEXML(XMLCOLUMN,
'/xpath/goes/here/text()', 'a new value')
WHERE
xml_id = p_xml_id;

No comments:

Labels

Blog Archive

Contributors