Skip to content
Advertisement

‘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

Advertisement

Answer

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
);
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement