문제

I get the following XML from a request:

<records>
  <record>
    <field name="code" value="1"/>
    <field name="dexcription" value="MyName"/>
    <field name="id" value="666">
  </record>
  <record>
    <field name="code" value="2"/>
    <field name="dexcription" value="MyName"/>
  </record>
  ...
</records>

The first record was processed successfully, returning the element "id"; the second was not, and so returned without this element.

I need to write an XML SQL query based returning these two columns ("code" and "id"), but only records that were processed successfully. I tried to use XMLType, but it still fails. Can anyone help me?

Thanks in advance, and sorry for my "googled" English.

도움이 되었습니까?

해결책

I found the solution:

SELECT EXTRACT (COLUMN_VALUE, '/record/field[@name="code"]/@value').GETSTRINGVAL () AS CODE,
       EXTRACT (COLUMN_VALUE, '/record/field[@name="id"]/@value').GETSTRINGVAL () AS ID
  FROM TABLE (XMLSEQUENCE (XMLTYPE (:XXML).EXTRACT ('/records/record')))
 WHERE EXTRACT (COLUMN_VALUE, '/record/field[@name="id"]') IS NOT NULL
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top