Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

sql - 'SET' must be a type

I created the following types :

CREATE TYPE Adress AS Object (Street varchar2(50), PostalC number, Ville varchar2(50));
CREATE TYPE PhoneNumber;

A person can have a set of PhoneNumbers, when I try to create the Type Person :

CREATE TYPE Person AS Object (FirstName varchar2(50), LastName varchar2(50), Adr Adress, Mobile SET(PhoneNumber));

I get the following error :

Errors: TYPE PERSON Line/Col: 0/0 PL/SQL: Compilation unit analysis terminated Line/Col: 1/90 PLS-00488: 'SET' must be a type


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want an array of phone numbers for each person, define the phone number type as a nested table:

create or replace type address as object (
  street varchar2(50), postalc number, ville varchar2(50)
);
/

create or replace type phonenumber as table of varchar2(20);
/

create or replace type person as object (
  firstname varchar2(50), lastname varchar2(50), 
  adr address, mobile phonenumber
);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...