2017-05-12 6 views
0

Oracleからのデータと結合できる結果を返すように、SharePointリスト(例:http://services.odata.org/Northwind/Northwind.svc/Customers)をOracleからクエリする方法はありますか?OracleのSharePoint XML Webサービスをクエリ

このYoutubeビデオでは、最初にデータをテーブル化するプロセスについて説明しています。https://www.youtube.com/watch?v=-hqtSHx1owo。私は同じ結果を生成することができますが、最初にテーブルを作成する必要はありません。

**編集**

サンプルデータ:

<?xml version="1.0" encoding="utf-8"?> 
<feed xml:base="http://services.odata.org/Northwind/Northwind.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <id>http://services.odata.org/Northwind/Northwind.svc/Customers</id> 
    <title type="text">Customers</title> 
    <updated>2017-05-13T12:50:16Z</updated> 
    <link href="Customers" rel="self" title="Customers"/> 
    <entry> 
     <id>http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')</id> 
     <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="NorthwindModel.Customer"/> 
     <link href="Customers('ALFKI')" rel="edit" title="Customer"/> 
     <link href="Customers('ALFKI')/Orders" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" title="Orders" type="application/atom+xml;type=feed"/> 
     <link href="Customers('ALFKI')/CustomerDemographics" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CustomerDemographics" title="CustomerDemographics" type="application/atom+xml;type=feed"/> 
     <title/> 
     <updated>2017-05-13T12:50:16Z</updated> 
     <author> 
      <name/> 
     </author> 
     <content type="application/xml"> 
      <m:properties> 
       <d:CustomerID>ALFKI</d:CustomerID> 
       <d:CompanyName>Alfreds Futterkiste</d:CompanyName> 
       <d:ContactName>Maria Anders</d:ContactName> 
       <d:ContactTitle>Sales Representative</d:ContactTitle> 
       <d:Address>Obere Str. 57</d:Address> 
       <d:City>Berlin</d:City> 
       <d:Region m:null="true"/> 
       <d:PostalCode>12209</d:PostalCode> 
       <d:Country>Germany</d:Country> 
       <d:Phone>030-0074321</d:Phone> 
       <d:Fax>030-0076545</d:Fax> 
      </m:properties> 
     </content> 
    </entry> 
    <link href="http://services.odata.org/Northwind/Northwind.svc/Customers?$skiptoken='ERNSH'" rel="next"/> 
</feed> 
+0

リンクが動作しません。サンプルデータを表示してください – OldProgrammer

+0

TABLE関数をご覧ください - https://oracle-base.com/articles/misc/pipelined-table-functions#table_functions – OldProgrammer

答えて

0

OK、この質問は、私の興味を得ました。ここでは、解体されたソリューションです。私はXML文字列をハードコードしました。その代わりに、UTL_HTTPを呼び出してデータを取得し、それを関数に渡す必要があります。

CREATE TYPE test_row_Type AS OBJECT (
    id   VARCHAR2(100), 
    customer_id varchar2(50) 

); 

CREATE TYPE test_tab_type IS TABLE OF test_row_Type; 


create table dummy (id varchar2(100), other_stuff varchar2(100)); 
insert into dummy values('http://services.odata.org/Northwind/Northwind.svc/Customers','HAVE A NICE DAY!'); 
commit; 


create or replace function get_data_func(P_xml IN VARCHAR2) return test_tab_type 
as 
    l_tab test_tab_type := test_tab_type(); 
    l_row test_row_Type; 
    D_id varchar2(100); 
    D_cust varchar2(100); 
begin 
    l_tab.extend; 

with xml_data as 
(select xmltype(p_xml) xml_result from dual) 
select extractvalue(xml_result,'/feed/id','xmlns="http://www.w3.org/2005/Atom"'), 
extractvalue(xml_result,'/feed/entry/content/m:properties/d:CustomerID','xmlns="http://www.w3.org/2005/Atom" 
      xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata 
      xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"') 
into d_id, d_cust 
from xml_data; 

    l_row := test_row_type(d_id, d_cust); 
    l_tab(l_tab.last) := l_row; 
    RETURN l_tab; 
end get_data_func; 

select * from 
table(get_data_func('<feed xml:base="http://services.odata.org/Northwind/Northwind.svc/" 
xmlns="http://www.w3.org/2005/Atom" 
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <id>http://services.odata.org/Northwind/Northwind.svc/Customers</id> 
     <entry> 
     <updated>2017-05-13T12:50:16Z</updated> 
     <author> 
      <name/> 
     </author> 
     <content type="application/xml"> 
      <m:properties> 
       <d:CustomerID>ALFKI</d:CustomerID> 
      </m:properties> 
     </content> 
    </entry> 
</feed>')) t1, 
dummy 
where t1.id = dummy.id 

enter image description here

P_XMLパラメータ> 32Kあれば、それは動作しませんので注意してください。より大きいxml文字列を渡す必要がある場合は、型をCLOBまたはXMLTYPEに変更します。

関連する問題