日期:2014-05-17 浏览次数:20807 次
-- 换一种思路可以用可变数组: set serveroutput on declare type tabletype1 is table of varchar2(9) index by binary_integer; table1 tabletype1; begin table1(1):='成都市'; table1(2):='北京市'; table1(3):='青岛市'; dbms_output.put_line('总记录数:'||to_char(table1.count)); dbms_output.put_line('第一条记录:'||table1.first); dbms_output.put_line('最后条记录:'||table1.last); dbms_output.put_line('第二条的前一条记录:'||table1.prior(2)); dbms_output.put_line('第二条的后一条记录:'||table1.next(2)); end;
------解决方案--------------------
SQL> set serveroutput on; SQL> SQL> declare 2 cursor cu is 3 select ename from emp where deptno = 10; 4 type enametype is table of varchar2(10); 5 etype enametype; 6 begin 7 open cu; 8 fetch cu bulk collect 9 into etype; 10 dbms_output.put_line(etype(cu%rowcount)); 11 close cu; 12 end; 13 / MILLER PL/SQL procedure successfully completed