Skip to Main Content
  • Questions
  • I cannot create the Type "investments_ty".It gives "created with compilation errors." .Can one explain me how to fix this error? Thanks..

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Subo.

Asked: August 31, 2016 - 12:48 pm UTC

Last updated: August 31, 2016 - 3:36 pm UTC

Version: 11.2

Viewed 1000+ times

You Asked

create type address_ty as object(
stnumber number,
stname varchar(9),
suburb char(4),
state char(9),
pin number
)
/


create type extraarray as varray(3) of char(9)
/

create type stocks_ty as object(
company char(5),
cprice number(2,2),
extrad extraarray,
ldivident number(1,2),
expershr number(2,2)
)
/


create type investments_ty as object(
comapany ref stocks_ty,
pprice number(2,2),
date varchar(9),
qty number(6)
)
/

and Chris said...

Date is a reserved word. You need to give that attribute a different name:

SQL> create type investments_ty
  2  as object  (
  3      comapany ref stocks_ty,
  4      pprice number ( 2,2 ) ,
  5      date varchar ( 9 ) ,
  6      qty    number ( 6 ) );
  7  /

Warning: Type created with compilation errors.

SQL> sho err
Errors for TYPE INVESTMENTS_TY:

LINE/COL ERROR
-------- ---------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
5/5      PLS-00330: invalid use of type name or subtype name
SQL>
SQL> create type investments_ty
  2  as object  (
  3      comapany ref stocks_ty,
  4      pprice number ( 2,2 ) ,
  5      price_date varchar ( 9 ) ,
  6      qty    number ( 6 ) ) ;
  7  /

Type created.


Is this answer out of date? If it is, please let us know via a Comment