2014-10-10 59 views
0

我已經將一個xml導入到oracle中,我正在使用列類型Xmltype。Oracle錯誤ora-19025 Xmltype

這裏是XML的結構:

<Release> 
<ReleaseId> 
<GRid>A10320WA0003483489</GRid> 
<ICPN IsEan="false">3610151317086</ICPN> 
<CatalogNumber Namespace="UPC">3610151317086</CatalogNumber> 
<ProprietaryId Namespace="ADAM_ID">551247405</ProprietaryId> 
</ReleaseId> 
<ReleaseReference>R551247405</ReleaseReference> 
<ReferenceTitle> 
<TitleText>Tony Bennett: 101 Hits - I Left My Heart in San Francisco</TitleText> 
</ReferenceTitle> 
<ReleaseResourceReferenceList> 
<ReleaseResourceReference>A551248137</ReleaseResourceReference> 
<ReleaseResourceReference>A551248136</ReleaseResourceReference> 
<ReleaseResourceReference>A551248070</ReleaseResourceReference> 
<ReleaseResourceReference>A551248074</ReleaseResourceReference> 
<ReleaseResourceReference>A551248041</ReleaseResourceReference> 
<ReleaseResourceReference>A551247836</ReleaseResourceReference> 
</ReleaseResourceReferenceList> 

這裏是選擇THA我使用

select extractvalue(value (sr),'*/ReleaseId/ISRC') as ISRC 
     ,extractvalue(value (sr),'*/ReleaseId/GRid')as GRid 
     ,extractvalue(value (sr),'*/ReleaseId/ICPN')as ICPN 
     ,extractvalue(value (sr),'*/ReleaseId/CatalogNumber')as CatalogNumber 
     ,extractvalue(value (sr),'*/ReleaseId/ProprietaryId')as ProprietaryId 
     ,extractvalue(value (sr),'*/ReferenceTitle/TitleText')as TitleText 
     ,extractvalue(value (sr),'*/ReleaseType')as ReleaseType 
     ,extractvalue(value (st),'*/ReleaseResourceReference')as teste 
from xml_ddex x, 
table(xmlsequence (extract(dados, '*/ContainedReleaseList/Release')))sr, 
table(xmlsequence(extract(value(sr),'*/ReleaseResourceReferenceList')))st 

誰能幫助我?由於

+0

周杰倫,讓我看看你的預期的結果。我無法識別你的問題中有哪些「dados」和「xml_ddex」。 – nop77svk 2014-10-11 07:26:05

+0

...我需要知道你想達到什麼目的。顯然,'teste'別名列是你的問題,但是這並不能告訴我你需要什麼作爲查詢輸出。 – nop77svk 2014-10-11 07:44:22

回答

1

基於一些猜測你的數據和你的預期結果的事實,這可能是你以後的查詢:

select --+ no_merge(SR) 
    SR.isrc, SR.grid, SR.icpn, SR.catalog_number, SR.proprietary_id, SR.title_text, SR.release_type, 
    ST.rel_res_ref as teste 
from xml_ddex X 
    cross join xmltable(
     '*/ContainedReleaseList/Release' 
     passing X.dados 
     columns 
      rel_res_ref_list$  xmltype path '/Release/ReleaseResourceReferenceList', 
      ISRC     varchar2(200) path '/Release/ReleaseId/ISRC', 
      GRid     varchar2(200) path '/Release/ReleaseId/GRid', 
      ICPN     varchar2(200) path '/Release/ReleaseId/ICPN', 
      catalog_number   varchar2(200) path '/Release/ReleaseId/CatalogNumber', 
      proprietary_id   varchar2(200) path '/Release/ReleaseId/ProprietaryId', 
      title_text    varchar2(200) path '/Release/ReferenceTitle/TitleText', 
      release_type   varchar2(200) path '/Release/ReleaseType' 
    ) SR 
    cross join xmltable(
     '/ReleaseResourceReferenceList/ReleaseResourceReference' 
     passing SR.rel_res_ref_list$ 
     columns 
      rel_res_ref    varchar2(200) path '/ReleaseResourceReference' 
    ) ST 
; 

我對no_merge一絲遺憾。在我的測試環境中,我無法讓查詢在沒有提示的情況下工作;這是拋出ORA-600例外。


上的一些部分猜測XML的測試...

with xml_ddex as (
    select xmltype('<?xml version="1.0" ?> 
     <SomeRootElementIGuessThereIs> 
      <ContainedReleaseList> 
       <Release> 
        <ReleaseId> 
         <GRid>A10320WA0003483489</GRid> 
         <ICPN IsEan="false">3610151317086</ICPN> 
         <CatalogNumber Namespace="UPC">3610151317086</CatalogNumber> 
         <ProprietaryId Namespace="ADAM_ID">551247405</ProprietaryId> 
        </ReleaseId> 
        <ReleaseReference>R551247405</ReleaseReference> 
        <ReferenceTitle> 
         <TitleText>Tony Bennett: 101 Hits - I Left My Heart in San Francisco</TitleText> 
        </ReferenceTitle> 
        <ReleaseResourceReferenceList> 
         <ReleaseResourceReference>A551248137</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248136</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248070</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248074</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248041</ReleaseResourceReference> 
         <ReleaseResourceReference>A551247836</ReleaseResourceReference> 
        </ReleaseResourceReferenceList> 
       </Release> 
       <Release> 
        <ReleaseId> 
         <GRid>A10320WA0003483489</GRid> 
         <ICPN IsEan="false">3610151317086</ICPN> 
         <CatalogNumber Namespace="UPC">3610151317086</CatalogNumber> 
         <ProprietaryId Namespace="ADAM_ID">551247405</ProprietaryId> 
        </ReleaseId> 
        <ReleaseReference>R551247405</ReleaseReference> 
        <ReferenceTitle> 
         <TitleText>Tony Bennett: 102 Hits - I Left My Head in Fresno</TitleText> 
        </ReferenceTitle> 
        <ReleaseResourceReferenceList> 
         <ReleaseResourceReference>A551248137</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248136</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248070</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248074</ReleaseResourceReference> 
         <ReleaseResourceReference>A551248041</ReleaseResourceReference> 
         <ReleaseResourceReference>A551247836</ReleaseResourceReference> 
        </ReleaseResourceReferenceList> 
       </Release> 
      </ContainedReleaseList> 
     </SomeRootElementIGuessThereIs>' 
    ) as dados 
    from dual 
) 
select --+ no_merge(SR) 
    SR.isrc, SR.grid, SR.icpn, SR.catalog_number, SR.proprietary_id, SR.title_text, SR.release_type, 
    ST.rel_res_ref as teste 
from xml_ddex X 
    cross join xmltable(
     '*/ContainedReleaseList/Release' 
     passing X.dados 
     columns 
      rel_res_ref_list$  xmltype path '/Release/ReleaseResourceReferenceList', 
      ISRC     varchar2(200) path '/Release/ReleaseId/ISRC', 
      GRid     varchar2(200) path '/Release/ReleaseId/GRid', 
      ICPN     varchar2(200) path '/Release/ReleaseId/ICPN', 
      catalog_number   varchar2(200) path '/Release/ReleaseId/CatalogNumber', 
      proprietary_id   varchar2(200) path '/Release/ReleaseId/ProprietaryId', 
      title_text    varchar2(200) path '/Release/ReferenceTitle/TitleText', 
      release_type   varchar2(200) path '/Release/ReleaseType' 
    ) SR 
    cross join xmltable(
     '/ReleaseResourceReferenceList/ReleaseResourceReference' 
     passing SR.rel_res_ref_list$ 
     columns 
      rel_res_ref     varchar2(200) path '/ReleaseResourceReference' 
    ) ST 
; 

... ...產量

A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551248137 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551248136 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551248070 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551248074 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551248041 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 101 Hits - I Left My Heart in San Francisco  A551247836 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551248137 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551248136 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551248070 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551248074 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551248041 
A10320WA0003483489 3610151317086 3610151317086 551247405 Tony Bennett: 102 Hits - I Left My Head in Fresno    A551247836