Search code examples
sqloracleoracle11gobject-relational-model

I am trying to alter a type in object relational model to add a member function to it, but it keeps giving me errors


This Emp_t type is the one I want to alter

create type Emp_t as object(
eno number(4),
ename varchar2(15),
slary number(8,2),
dependents Dependtb_t,
edept ref Dept_t
);
/

This is the DDL commant to alter Emp_t type

alter type Emp_t
add member function calChildAllowance(eno number(4)) return float
cascade;

But it gives me this error:

ERROR at line 1:
ORA-06545: PL/SQL: compilation error - compilation aborted
ORA-06550: line 12, column 49:
PLS-00103: Encountered the symbol "(" when expecting one of the following:
:= . ) , @ % default character
The symbol ":=" was substituted for "(" to continue.
ORA-06550: line 0, column 0:
PLS-00565: EMP_T must be completed as a potential REF target (object type)

Image of the error attached here. I am using SQL Command Line for this

I wanted to alter the Emp_t type to add a member function.


Solution

  • It looks like you do not need precision in number data type:

    alter type Emp_t
    add member function calChildAllowance(eno number) return float
    cascade;