标签:
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