declare
cursor emptext is
select textid,textname from t_text where textname='ooo';
type t_text_type is table of varchar2(100);
ename_table t_text_type;
begin
open emptext;
fetch emptext bulk collect into ename_table;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
close emptext;
end;
cursor emptext is
select textid,textname from t_text where textname='ooo';
type t_text_type is table of varchar2(100);
ename_table t_text_type;
begin
open emptext;
fetch emptext bulk collect into ename_table;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
close emptext;
end;
修改下:参考如下:
DECLARE
CURSOR EMPTEXT IS
SELECT empno,ename FROM scott.emp WHERE deptno = 20;
TYPE T_TEXT_TYPE IS TABLE OF VARCHAR2(100);
ENAME_TABLE T_TEXT_TYPE;
x T_TEXT_TYPE;
BEGIN
OPEN EMPTEXT;
FETCH EMPTEXT BULK COLLECT
INTO ENAME_TABLE,x;
FOR I IN 1 .. ENAME_TABLE.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(ENAME_TABLE(I));
END LOOP;
CLOSE EMPTEXT;
END;
/