简体   繁体   中英

How to add Array of one entity while creating table in Oracle 11g Express Edition?

I am trying to create a table in my data base with object publisher defined as

create type publisher as object
(  pname varchar(20),
   branch varchar(20)
)

and then a book object as

create type book as object(
title varchar(20),
pub_date date,
publisher publisher array[3],
keywordset varchar(20) multiset
)

and finally a table from book object as

create table Books of book

But, I am getting an error while creating object of book as follows

Error at line 4: PLS-00103: Encountered the symbol "ARRAY" when expecting one of the following:

:= . ( ) , @ % not null range default external character

  1. title varchar(20),
  2. pub_date date,
  3. publisher publisher array[3],
  4. keywordset varchar(20) multiset
  5. )

Please help me resolve it.

You have to create an array sub type before using it. It should be outside the object. and i don't know why you are using MULTISET in their.

You can create equivalent table using following code.

 create type publisher as object
    (  pname varchar(20),
       branch varchar(20)
    )

    create type t_publisher as  varray(3) of publisher

    create type book as object(
    title varchar(20),
    pub_date date,
    publishr t_publisher,
    keywordset varchar(20)
    )


    create table Books of book

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM