问题
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