我的任务之一是: 方法AvgReviewScore()返回相册的平均评分,不包括匿名评论者的评分,即评论为空的REVIEWER_NAME。
首先我写了SQL: (这是面向数据库的分配)
create or replace TYPE BODY ALBUM_TYPE AS
member function AvgReviewScore return AvgReviewScore_type AS
AVGtable AvgReviewScore_type := AvgReviewScore_type(null,null);
BEGIN
select deref(b.album).title,round(avg(b2.reviewscore),2)
into AVGtable
from album_artist_table b,table(deref(b.album).review) b2
where b2.reviewername is not null
group by deref(b.album).title;
return AVGtable;
END AvgReviewScore;
END;
请问如何将此sql转换为成员函数?
我尝试创建一个名为:AvgReviewScore_type
的类型然后我创建类型主体成员函数如下:
{{1}}
但它不起作用,是否有人知道原因?
答案 0 :(得分:0)
我猜您的问题信息不完整,取决于给出的内容,请参阅下面的示例。我希望它会对你有所帮助。
Create type exmpl_type as object (
num number,
member function func(p in number) return number
);
/
create type body exmpl_type as
member function func(p in number)
return number is
begin
return num/p;
end func;
end;
/