2017-12-03 105 views
1

我試圖寫一個查詢來獲取IP地址,該地址是另一個嵌套表的引用的嵌套表的引用。獲取嵌套表的引用的值

create type t_pc as object (
     Nserie number(20), 
     adrIP VARCHAR(20), 
     cpu VARCHAR(20) 
    ); 

create type t_instatype as object(
    dateinst VARCHAR(20) , 
    refPC REF t_pc 
); 

create type t_installations as table of t_instatype ; 

create type t_logiciel as object (
    nomlogi VARCHAR(20) , 
    versionL VARCHAR(20) , 
    editeur VARCHAR(20), 
    installationsR t_installations 
); 

create type t_refLogiciel as object (
    refLogiciel ref t_logiciel 
); 

create type t_reflogiciels as table of t_reflogiciel ; 

create type t_adrType as object (
    rue VARCHAR(20) , 
    ville VARCHAR(20) 
); 

create type t_Depatement as object (
     codeDept number(20) , 
     nomDept varchar(20) , 
     budget varchar(20) , 
     refLogicielR t_reflogiciels , 
     AdrR t_adrType 
    ); 

下面是表:

create table Departement of t_Depatement 
    nested table refLogicielR store as rlogi ; 

create table Logiciel of t_logiciel 
    nested table installationsR store as insta ; 

create table PC of t_pc ; 

這裏的圖片顯示了我的數據

"MyTables "

我的查詢應檢索nomDept其中ADRIP是等於=「192.168表.2 .4;

預先感謝您

回答

1

您可以瘦約Performing DML Operations on Collections (at: Unnesting Queries with Multilevel Collections) on Oracle Objects docs

Unnesting查詢,也可以使用多級收藏,無論可變數組和嵌套表。

這是查詢:

SELECT d.nomDept 
FROM Departement d, 
    table(d.refLogicielR) l, 
    table(l.refLogiciel.installationsR) i 
WHERE i.refPC.adrIP = '192.168.2.4' 

我想,這樣的回答,我贏得未來Oracle對象奇特的水平。

+1

謝謝曼 這就是我尋找的確切解決方案 –