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!

Solving ORA-19025: EXTRACTVALUE returns value of only one node for occurance X

LaurySep 24 2017 — edited Sep 28 2017

Hi,

I have a piece of XML document that have this format (working with Oracle RDBMS 12c):

LOCAL_XML

--------------------------------------------------------------------------------

<?xml version="1.0" encoding="US-ASCII"?>

<GeocodeResponse>

  <status>OK</status>

  <result>

    <type>street_address</type>

    <formatted_address>Via Pasubio, 34, 12025 Dronero CN, Italy</formatted_address>

    <address_component>

      <long_name>34</long_name>

      <short_name>34</short_name>

      <type>street_number</type>

    </address_component>

  ...

  </result>

  <result>

    <type>locality</type>

    <type>political</type>

    <formatted_address>12025 Dronero, Province of Cuneo, Italy</formatted_address>

    <address_component>

      <long_name>Dronero</long_name>

      <short_name>Dronero</short_name>

      <type>locality</type>

      <type>political</type>

    </address_component>

    <address_component>

...

I wish to extract the first occurence of the element <formatted_address>, that is in this example: Via Pasubio, 34, 12025 Dronero CN, Italy.

That piece of XML is defined as XMLtype column (geo_xml), in table t_geo_xmltype2.

select

    extractvalue(a.geo_xml, '/GeocodeResponse/result/formatted_address') as addr

from

    t_geo_xmltype2 a;

As starting point, the query above returns this error:

ERROR at line 4:

ORA-19025: EXTRACTVALUE returns value of only one node

How can I extract just the first value encountered for element <formatted_address>?

Thanks by advance for any tip.

Kind Regards

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2017
Added on Sep 24 2017
9 comments
28,436 views