exception 的管辖范围?

[复制链接]
查看11 | 回复4 | 2005-4-13 10:15:00 | 显示全部楼层 |阅读模式
select field1 from table_name where conditions
--actions

exception
when no_data_found then
--未找到数据的处理
message('not found!');
--操作
----------------------------
exception
when no_data_found then
的管辖范围有多大,什么时候结束?如果我想在这些语句后做其他操作,怎么结束exception区域。
回复

使用道具 举报

千问 | 2005-4-13 10:15:00 | 显示全部楼层
BEGIN
  select field1 from table_name where conditions
  --actions
EXCEPTION --exception
  when no_data_found then
     --未找到数据的处理
     message('not found!');
END;
--后继操作
有一个要注意一下,EXCEPTION里的代码不能再有例外,如果有的话,后继操作还是不能被进行.
你可以试一下.
回复

使用道具 举报

千问 | 2005-4-13 10:15:00 | 显示全部楼层
谢谢,在测试中,好象还是有问题!
begin
--操作语句1
BEGIN
  select field1 from table_name where conditions
  --actions
EXCEPTION --exception
  when no_data_found then
     --未找到数据的处理
     message('not found!');
END;
--操作语句2
end;
我是想实现--操作语句2,而不想--操作语句2被exception管辖
下午再测试一下!
回复

使用道具 举报

千问 | 2005-4-13 10:15:00 | 显示全部楼层
就上面的代码看来,你的操作语句2和上面的EXCEPTION一点关系也没有,它不会影响你的语句2的.除非下面还有别的EXCEPTION,或是调用它的地方有EXCEPTION.
回复

使用道具 举报

千问 | 2005-4-13 10:15:00 | 显示全部楼层
明白你的意思了,谢谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行