Code:
CREATE OR REPLACE TYPE Address AS OBJECT (
city VARCHAR2(15),
state VARCHAR2(15),
pin NUMBER(6));
CREATE OR REPLACE TYPE Student AS OBJECT (
id NUMBER(3),
fName VARCHAR2(10),
lName VARCHAR2(10),
dob DATE,
phone NUMBER(10),
address Address
) NOT FINAL;
CREATE OR REPLACE TYPE Course UNDER Student (
dept VARCHAR2(20),
sem VARCHAR2(20));
Errors:
Error for Type Student:
Warning: Type created with compilation errors.
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
7/9 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
Error for Type Course:
Warning: Type created with compilation errors.
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/19 PLS-00905: object SYS.STUDENT is invalid
I know the error in Type Course would be resolved after clearing the error in Type Student, but adding it just in case.
You can't have "address Address"... the property/column name conflicts with the type name. Rename it something else: "student_address Address", or rename the types so you can use "address addresstype" or something of that nature. E.g.:
CREATE OR REPLACE TYPE AddressType AS OBJECT (
city VARCHAR2(15),
state VARCHAR2(15),
pin NUMBER(6));
CREATE OR REPLACE TYPE StudentType AS OBJECT (
id NUMBER(3),
fName VARCHAR2(10),
lName VARCHAR2(10),
dob DATE,
phone NUMBER(10),
address AddressType -- avoids name conflict
) NOT FINAL;
CREATE OR REPLACE TYPE CourseType UNDER StudentType (
dept VARCHAR2(20),
sem VARCHAR2(20));