Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XPATH sum(node-set) function using PLSQL

ow008057Jun 25 2004 — edited Aug 29 2007

Hi all,
I want to sum the contents of an element in an XML-document using xpath. Currently i get the error message 'ORA-31012 Given XPATH expression not supported'. This is clear: in 9iR2 i can't use the complete xpath syntax.

Is there an alternative way without having to use all those very low-level dbms_xmldom-functions?

I can't (and don't want to) use XSLT inside my PL/SQL procedures.

thanks for all your help,
Bart

example:

declare
   l_xml    xmltype := xmltype('<a><b><amount>100.01</amount></b><b><amount>0.99</amount></b></a>');
begin
   for r in (select extract(l_xml, 'sum(//amount/text())').getNumberVal() as total
             from dual)
   loop
   -- n.b. loop returns only one (1) row !
      dbms_output.put_line('total = '||r.total);
   end loop;
end;

Message was edited by:
ow008057

Message was edited by:
ow008057

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2007
Added on Jun 25 2004
4 comments
9,393 views