ORA-22912 specified column or attribute is not a nested table type /oracle creating nested table

折月煮酒 提交于 2021-01-29 07:54:59

问题


I was working with OODB and tried to make a nested table using two tables. I am posting code here

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);

The code intends to create a table branch by branch type and then creates a type Publisher Type which then try to create a nested table.

create table Publishers of PublisherType NESTED TABLE
branches STORE as branchTable

But the above code gives error saying that the specified type is not a nested table type. Please help me out.


回答1:


You seem to be mixing up your types, between objects, tables of objects, and object tables. This builds, with a made-up addrtype since that wasn't described in the question:

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.

The main differences are:

create type BranchTableType as table of BranchType

as a table type rather than a table, instead of:

create table BranchTableType of BranchType;

And:

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

with the nested table type, instead of:

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

And:

branches STORE as branchTableTypeStore

as a storage name not type, instead of:

branches STORE as branchTable

But I'm not entirely sure what you'll be doing and if this is exactly what you want. Hopefully this will point you in the right direction anyway...



来源:https://stackoverflow.com/questions/16785647/ora-22912-specified-column-or-attribute-is-not-a-nested-table-type-oracle-creat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!