get_age
以下代码使用 oracle sql*plus创建一个带有函数的对象表。
Create Type C_type as Object(
Cname varchar(30),
dob Date,
classification Number,
sample_clip Blob
)
/
ALTER TYPE C_type
ADD MEMBER FUNCTION get_age RETURN INTEGER;
CREATE OR REPLACE TYPE BODY C_type AS
MEMBER FUNCTION get_age RETURN INTEGER IS
currenttime_age integer;
BEGIN
currenttime_age := (SYSDATE - dob)/365.25;
RETURN currenttime_age;
END get_age;
END;
/
我的目的是添加另一个返回字符的函数
- 分类为“短”(如果低于 5)、“中”(在 5-45 之间)和“长”(超过 45)