create TABLE COURSE
( COURSE_NO NUMBER(38),
DESCRIPTION VARCHAR2(50),
COST NUMBER(9,2),
PREREQUISITE NUMBER(8),
CREATED_BY VARCHAR2(30),
CREATED_DATE DATE,
MODIFIED_BY VARCHAR2(30),
MODIFIED_DATE DATE
);
INSERT INTO COURSE VALUES(1,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE );
INSERT INTO COURSE VALUES(2,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE);
INSERT INTO COURSE VALUES(3,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE);
INSERT INTO COURSE VALUES(4,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE);
INSERT INTO COURSE VALUES(5,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE);
INSERT INTO COURSE VALUES(6,'22223',1,1,'20150101',SYSDATE,'20150101',SYSDATE);
DECLARE
rn number;
CURSOR course_cur IS SELECT course_no FROM COURSE;
--type delArray1 is table of COURSE%ROWTYPE index by binary_integer;
type delArray1 is table of COURSE.COURSE_NO%TYPE index by binary_integer;--%TYPE实际对应表中一列的数据类型
cur_result delArray1;
BEGIN
rn := 2;
OPEN course_cur;
for i in 1..3 loop
FETCH course_cur bulk collect into cur_result limit rn;
for i in 1..rn loop
print 'loop COURSE_NO1: '||cur_result(i);
end loop;
print 'commit ' ;
END LOOP;
close course_cur;
END;
本文参考:http://blog.itpub.net/750077/viewspace-2075986/
文章
阅读量
获赞