我有一个房子对象,里面有房子信息。我正在创建另一个对象 - 村庄 - 每个可以包括2到50个房子。我正在努力创建村庄对象,更具体地说是在循环功能中 - 我希望村庄变形包括一系列房屋和成员函数返回一个村庄的人口。
众议院对象
CREATE or REPLACE type house as object (
house_no number,
road_name varchar2(20),
postcode varchar2(10),
no_of_residents number,
member function pass(h house) return number
);
/
乡村对象
CREATE or REPLACE type village_array is varray(50) of house (
village_id number,
village_name varchar2(25),
population number,
member function village_population(p v_population) return number
);
/
村庄对象团体
CREATE or REPLACE type body village_array as
member function village_population(p v_population) return number is
begin
/*
This is where I am clearly struggling to sum all of the house residents
and returning the population of a village. I have a feeling it is some
kind of for loop in here somewhere
*/
then
return ;
else
return ;
end;
end;
/
我的村庄表
CREATE Table Village (
village_id number,
village village_array
)