本帖最后由 goberl 于 2012-3-8 08:49 编辑
请问下面两种方法有什么区别,谢谢!!
--方法1
cursor c_student is select age from student
open c_2;
loop
Fetch c_student into v_age;
--more todo
end loop;
close c_2复制代码--方法2
for item (select agefrom student) loop
v_age:=item.age;
--more todo
end loop;复制代码平时为了方便都是用的方法2,不知道有什么弊端没有!!
CREATE OR REPLACE PROCEDURE t_pro_rc_change
AS
TYPE cs IS REF CURSOR;
TYPE v_list IS TABLE OF VARCHAR2(200);
cs_sql VARCHAR2(1000);
c_studentcs;
v_age v_list;
BEGIN
cs_sql := 'select agefrom student';
OPENc_studentFOR cs_sql;
FETCHc_studentBULK COLLECT INTO v_age;
CLOSE rc;
FOR i IN v_age.FIRST .. v_age.LAST
LOOP
...
END LOOP;