I have a SQL table that contains an XMLType column. I need to iterate through each row and extract values from the column.
The XML contain multiple children with the same will look like this:
<parent>
<child>Test</child>
<child>Test1</child>
<child>Test2</child>
</parent>
My goal is to take the value from each child and append to a string. However, I am having issues extracting the value.
My current solution:
DECLARE
sample VARCHAR(2000);
BEGIN
FOR row IN (SELECT xml_column FROM table)
LOOP
FOR child in (SELECT EXTRACT('/parent/child') ...
LOOP
....
END LOOP;
END LOOP;
END;
My first issue is I cannot seem to get the individual values. I've used both EXTRACT and EXTRACTVALUE but the best I've gotten is 'TEST1TEST2...'.
Second, if I try using row.XML_COLUMN it complains that it does not exist.