A possible workaround is to use PL / SQL blocks:
DECLARE xml VARCHAR2(32000) := '<theRange> <theRow><First>Bob</First><Last>Smith</Last><Age>30</Age></theRow> <theRow><First>Sue</First><Last>Jones</Last><Age>34</Age></theRow> ... ... ... <theRow><First>Tom</First><Last>Anderson</Last><Age>39</Age></theRow> <theRow><First>Ali</First><Last>Grady</Last><Age>45</Age></theRow> </theRange>'; CURSOR C (p1 INTEGER, p2 INTEGER) IS SELECT * FROM ( SELECT extractvalue(column_value, '/theRow/First') FIRST, extractvalue(column_value, '/theRow/Last') LAST, to_number(extractvalue(column_value, '/theRow/Age')) Age FROM TABLE(XMLSequence(XMLTYPE(xml).extract('/theRange/theRow')))) ) WHERE age BETWEEN p1 AND p2; BEGIN FOR R IN C (30,35) LOOP dbms_output.put_line(R.First||', '||R.Last||', '||R.Age); END LOOP; END;
(Completely untested)
EDIT:
As an insert, you can try:
DECLARE xml VARCHAR2(32000) := '<theRange> <theRow><First>Bob</First><Last>Smith</Last><Age>30</Age></theRow> <theRow><First>Sue</First><Last>Jones</Last><Age>34</Age></theRow> ... ... ... <theRow><First>Tom</First><Last>Anderson</Last><Age>39</Age></theRow> <theRow><First>Ali</First><Last>Grady</Last><Age>45</Age></theRow> </theRange>'; BEGIN INSERT INTO temp_table(last,first,age) SELECT last, first, age FROM ( SELECT extractvalue(column_value, '/theRow/First') FIRST, extractvalue(column_value, '/theRow/Last') LAST, to_number(extractvalue(column_value, '/theRow/Age')) Age FROM TABLE(XMLSequence(XMLTYPE(xml).extract('/theRange/theRow')))) ) WHERE age BETWEEN 30 AND 35; END;
Dcookie
source share