plsql_列集_collection_type is table of

SQL> declare
  2  type type_dept is table of dept.deptno%type;--就是对应表中某列的列集合
  3  dept1 type_dept;
  4  dname dept.dname%type;
  5  loc dept.loc%type;
  6  begin
  7  dept1:=type_dept(10,20,25,30,40);
  8  for i in dept1.first ..dept1.last loop
  9   select dname,loc into dname,loc from dept where deptno=dept1(i);
 10   dbms_output.put_line(to_char(dept1(i))||':'||dname||','||loc);
 11  end loop;
 12  exception
 13  when no_data_found then
 14   dbms_output.put_line('no data');
 15  end;
 16  /
10:ACCOUNTING,NEW YORK
20:RESEARCH,DALLAS
no data
PL/SQL 过程已成功完成。
SQL>
 
 
小结;在处理过程,一碰到问题就直接去处理异常了,然后就退出了,不会继续处理后面的数据
 
请使用浏览器的分享功能分享到微信等