简体   繁体   中英

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)

此处附有错误图片。我为此使用 SQL 命令行

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM