以前兩篇文章介紹了使用Collection和更新Collection的方法,這篇文章將要介紹如果需要生成一個新的Collection並且向其中添加數據的方法。

procedure insert_object(d in dept_array, d2 out dept_array)

is

begin

--dept_array is a collection.

d2 := dept_array();--give d2 the structure of that collection

for j in 1..d.count loop

d2.EXTEND;

d2(j) := department_type(d (j).dno, d (j).dno,d (j).dno);

end loop;

--Test data

for j in 1..d2.count loop

--update

d2(j).location := ''New Loc2_''||j;

INSERT INTO department_teststruct

VALUES (d2 (j).dno||j,d2 (j).name,d2 (j).location);

end loop;

end insert_object;
有問題Email我。