2013-05-28 25 views
0

我正在使用OODB並嘗試使用兩個表製作嵌套表。我在這裏ORA-22912指定的列或屬性不是嵌套表類型/ oracle創建嵌套表

create type BranchType as object(
address AddrType, 
phone1 integer, 
phone2 integer); 

create table BranchTableType of BranchType; 

create type PublisherType as object(
name varchar2(50),  
addr AddrType, 
branches BranchType); 

發佈代碼的代碼所創建的分支類型的表分支,然後創建一個類型的出版商類型,然後嘗試創建一個嵌套表。

create table Publishers of PublisherType NESTED TABLE 
branches STORE as branchTable 

但上面的代碼給出錯誤,說明指定的類型不是嵌套表類型。請幫助我。

回答

0

你似乎混淆了你的類型,對象,對象表和對象表之間的關係。這建立,以一個虛構的addrtype以來,在問題沒有得到描述:

create type addrtype as object(
city varchar2(20) 
) 
/

create type BranchType as object(
address AddrType, 
phone1 integer, 
phone2 integer) 
/

create type BranchTableType as table of BranchType 
/

create type PublisherType as object(
name varchar2(50),  
addr AddrType, 
branches BranchTableType) 
/

create table Publishers of PublisherType NESTED TABLE 
branches STORE as branchTableTypeStore 
/

SQL Fiddle

的主要區別是:

create type BranchTableType as table of BranchType 

作爲表類型,而不是一個表,而不是:

create table BranchTableType of BranchType; 

和:

create type PublisherType as object(
... 
branches BranchTableType) 

與嵌套表類型,我nstead的:

create type PublisherType as object(
... 
branches BranchType); 

和:

branches STORE as branchTableTypeStore 

作爲存儲不會打字,而不是:

branches STORE as branchTable 

但我不能完全保證你會喜歡什麼如果這正是你想要的。希望這會指出你在正確的方向...

+0

非常感謝你,我想做同樣的工作,但無法做到這一點。我弄亂了分支類型,弄亂了我的工作。但真的非常感謝你。 –