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!

How to extract multiple records from XML using extractValue or extract

jeffreehy-JavaNetJun 26 2014 — edited Jul 9 2014

Hi all,

I'm consuming a Web service from PL/SQL Stored Proc. and I'm getting this xml:

XML_DATA= <?xml version = '1.0' encoding = 'UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">

   <S:Body>

      <ns2:consultaCooperativistaResponse xmlns:ns2="http://unired.ws.com/">

         <return>

            <codError>0</codError>

            <codigoCooperativista>70039395</codigoCooperativista>

            <codigoCuenta>70057992</codigoCuenta>

            <descripcionTipoCuenta>APORTACIONES</descripcionTipoCuenta>

            <mensaje></mensaje>

            <nombreAfiliado>JEFFREEHY  TALAVERA DIAZ</nombreAfiliado>

         </return>

         <return>

            <codError>0</codError>

            <codigoCooperativista>70039395</codigoCooperativista>

            <codigoCuenta>70057993</codigoCuenta>

            <descripcionTipoCuenta>RETIRABLES</descripcionTipoCuenta>

            <mensaje></mensaje>

            <nombreAfiliado>JEFFREEHY  TALAVERA DIAZ</nombreAfiliado>

         </return>

      </ns2:consultaCooperativistaResponse>

   </S:Body>

</S:Envelope>

resp:= XMLType.createXML(soap_respond);

delete from session_temp_xml;

INSERT INTO SESSION_TEMP_XML ("ID", "XML_DATA")

  VALUES (1, resp);

  COMMIT;

OPEN p_recordset FOR

SELECT extractValue(x.column_value, '//codError') as codigo_error

      , extractValue(x.column_value, '//codigoCooperativista') as identidad

      , extractValue(x.column_value, '//codigoCuenta') as numero_cuenta

FROM SESSION_TEMP_XML s

   , TABLE(

        XMLSequence(

          extract(

            s.XML_DATA

          , '/ns2:consultaCooperativistaResponse/return'

           , 'xmlns:ns2="http://unired.ws.com/"'

          )

       )

       ) x;

I'm getting nothing.

An this is what I need.

CodError,          CodCoop       CodCTA     Descrip                        Nombre

0                      70039395     70057992    APORTACIONES       JEFFREEHY  TALAVERA DIAZ

0                      70039395     70057993    RETIRABLES            JEFFREEHY  TALAVERA DIAZ

Nedd help.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2014
Added on Jun 26 2014
1 comment
1,682 views