当前位置: 代码迷 >> Oracle开发 >> 怎么判断表变量为空,也就是没有数据
  详细解决方案

怎么判断表变量为空,也就是没有数据

热度:53   发布时间:2016-04-24 07:30:54.0
如何判断表变量为空,也就是没有数据?
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 );
  相关解决方案