时间:2021-07-01 10:21:17 帮助过:2人阅读
- 这篇文章将要介绍如果需要生成一个新的Collection并且向其中添加数据的方法。<br><br>procedure insert_object(d in dept_array, d2 out dept_array) is<br>begin<br><br> --First way to insert data into a new array.<br> SELECT CAST(MULTISET<br> (SELECT DNO, name, location FROM department_teststruct) AS<br> dept_array)<br> INTO l_dept_array<br> FROM DUAL;<br><br> --Second to insert data into a new array.<br> d2 := dept_array();<br> FOR j IN 1 .. d.COUNT LOOP<br> d2.EXTEND;<br> d2(j) := department_type(d(j).dno, d(j).name, d(j).location);<br> END LOOP;<br><br> --Test data<br> for j in 1 .. d2.count loop<br> --update<br> d2(j).location := ‘New Loc2_‘ || j;<br> INSERT INTO department_teststruct<br> VALUES<br> (d2(j).dno || j, d2(j).name, d2(j).location);<br> end loop;<br>end insert_object;
如何在Oracle中向Collection类型的变量中逐条插入数据
标签: