码迷,mamicode.com
首页 > 其他好文 > 详细

bulk collect no_data_found exception

时间:2015-09-19 06:07:49      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

Bulk collect当没有数据抛出异常跟implicit cursor 处理不一样。

先看一下implicit cursor的处理吧:

cl scr;
DECLARE
  l_descr hardware.descr%type;
BEGIN
  SELECT descr INTO l_descr FROM hardware WHERE aisle = 0 AND item = 0;
  dbms_output.put_line(Item was found);
EXCEPTION
WHEN no_data_found THEN
  dbms_output.put_line(Invalid item specified);
END;

bulk collect的处理就不一样。

cl scr;
DECLARE
type t_descr_list
IS
  TABLE OF hardware.descr%type;
  l_descr_list t_descr_list;
BEGIN
  SELECT descr bulk collect
  INTO l_descr_list
  FROM hardware
  WHERE aisle           = 0
  AND item              = 0;
  IF l_descr_list.count = 0 THEN
    raise no_data_found;
  END IF;
  dbms_output.put_line(Item was found);
EXCEPTION
WHEN no_data_found THEN
  dbms_output.put_line(Invalid item specified);
END;

 

bulk collect no_data_found exception

标签:

原文地址:http://www.cnblogs.com/cdjboy/p/4820789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!