ITPUB??ì3
ITPUB论坛 » Oracle开发 » 请教高手!

标题: 请教高手!
离线 hnzhengbc
一半是大海,一半是高山



精华贴数 0
个人空间 0
技术积分 102 (16609)
社区积分 33 (6134)
注册日期 2001-12-17
论坛徽章:0
      
      

发表于 2001-12-17 13:25 
请教高手!

各位大虾,这段代码有啥错误?为啥总出现ORA-06510: PL/SQL: unhandled user-defined exception?


declare
  name1 varchar2(20);
  birthday date;
  id1 number(3):=3;
  more_than_one_row exception;  
begin
  while id1>=0 loop
  select name into name1 from pltable where id=id1;
  if name1<>' ' then
    dbms_output.put_line('name is: '||name1);
  end if;
  select birthday into birthday from pltable where name=name1;
if birthday is not null then
    dbms_output.put_line(' birthday is: '||to_char(birthday,'dd-mm-yyyy'));
end if;
  id1:=id1-1;
  end loop;
  exception
  when no_data_found then
  dbms_output.put_line('no data found!');
  when too_many_rows then
  raise more_than_one_row;
  when more_than_one_row then
  dbms_output.put_line('more than one row!');  
when others then
dbms_output.put_line('unknown error!') ;
end;


__________________
禹,中国第一个流氓!
只看该作者    顶部
离线 srdyxy
一般会员



精华贴数 0
个人空间 0
技术积分 144 (12697)
社区积分 0 (49366)
注册日期 2001-11-12
论坛徽章:1
授权会员     
      

发表于 2001-12-18 14:55 
Exception里面应该不能再Raise  Exception!!


只看该作者    顶部
离线 hnzhengbc
一半是大海,一半是高山



精华贴数 0
个人空间 0
技术积分 102 (16609)
社区积分 33 (6134)
注册日期 2001-12-17
论坛徽章:0
      
      

发表于 2001-12-19 09:12 
谢谢srdyxy

问题的解决方法已经找到。只要将
when too_many_rows then
raise more_than_one_row;
when more_than_one_row then
dbms_output.put_line('more than one row!');
该为:
when too_many_rows then
begin
  raise more_than_one_row;
  exception
  when more_than_one_row then
  dbms_output.put_line('more than one row!');
end;
就可以了。


__________________
禹,中国第一个流氓!
只看该作者    顶部
离线 easyfree
去留无意 聚散两难


精华贴数 32
个人空间 0
技术积分 14126 (84)
社区积分 4061 (363)
注册日期 2001-9-24
论坛徽章:8
现任管理团队成员ITPUB元老ITPUB北京九华山庄2008年会纪念徽章管理团队2006纪念徽章会员2006贡献徽章授权会员
行业板块每日发贴之星ITPUB新首页上线纪念徽章    

发表于 2001-12-19 10:30 
真是奇怪的用法

已经有了预定义的TOO_MANY_ROWS, 为何还要多raise一次自己的exception? 直接dbms_output.put_line('more than one row!'); 不就可以了么?


__________________
看我非我我看我我亦非我
只看该作者    顶部
离线 hnzhengbc
一半是大海,一半是高山



精华贴数 0
个人空间 0
技术积分 102 (16609)
社区积分 33 (6134)
注册日期 2001-12-17
论坛徽章:0
      
      

发表于 2001-12-19 12:38 
不好意思!:)

这段程序没有实际意义,我只是看是否能有这样的用法。


__________________
禹,中国第一个流氓!
只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问