日期:2014-05-17  浏览次数:20742 次

如何判断表变量为空,也就是没有数据?
declare
TYPE emp_table_type is table of tbl_emp.n_emp_id%type INDEX BY BINARY_INTEGER;
  emptable emp_table_type;
  begin
select n_emp_id bulk collect into emptable from tbl_emp where n_emp_id=999;
--如果emptable为空
end;


如何判断表变量emptable为空,也就是没有数据?


------解决方案--------------------

有两个变量emptable.COUNT 和SQL%ROWCOUNT 可以判断:

dbms_output.put_line(emptable.COUNT );
dbms_output.put_line(SQL%ROWCOUNT );