oracle存储过程for循环中的异常处理
存储过程部分如下:
--定义一个游标
cursor mytemp is
select id,mobilephone from mytable where trim(lanmuid) =mylanmuid and kaiguan =1;
--开始遍历游标得到其值
for sms in mytemp loop
insert into send_box(content,usernumber)
values(content,sms.mobilephone) ;
end Loop;
我的问题是send_box这个表中对字段content,usernumber作了约束unique key不能重复,且这个表有很多的程序来向其中插入数据,虽然在上面这个循环中本身的数据不会重复,但是不能保证不会和此表中已有的数据产生重复,就会产生约束unique key异常。
所以我想在此循环中获取异常,如果异常发生就跳过,然后继续循环下面的数据,不能让此循环中止,因为中止后没法找到那个断点,接着循环了。先谢谢了。