ITPub博客

首页 > 数据库 > Oracle > 自定义ora报错信息

自定义ora报错信息

原创 Oracle 作者:masheng0925 时间:2015-10-11 11:56:13 0 删除 编辑
  1. DECLARE  
  2.   l_1 NUMBER := 10;  
  3.   l_2 NUMBER := 20;  
  4.   l_3 NUMBER := 30;  
  5.   PROCEDURE test_out  
  6.   (  
  7.     p1 IN NUMBER  
  8.    ,x1 IN OUT NUMBER  
  9.    ,x2 IN OUT NOCOPY NUMBER  
  10.   ) IS  
  11.   BEGIN  
  12.     x1 := p1;  
  13.     dbms_output.put_line('inside test_out, x1=' || x1);  
  14.     x2 := p1;  
  15.     dbms_output.put_line('inside test_out, x2=' || x2);  
  16.     raise_application_error(-20001, 'test NOCOPY');  
  17.   END;  
  18. BEGIN  
  19.   dbms_output.put_line('before, l_1=' || l_1 || ', l_2=' || l_2 ||  
  20.                        ', l_3=' || l_3);  
  21.   BEGIN  
  22.     --the OUT parameter has no value at all until the program terminates successfully,  
  23.     --unless you have requested use of the NOCOPY hint  
  24.     test_out(l_1, l_2, l_3);  
  25.   EXCEPTION  
  26.     WHEN OTHERS THEN  
  27.       dbms_output.put_line('SQLCODE => ' || SQLCODE || ', SQLERRM => ' ||  
  28.                            SQLERRM);  
  29.   END;  
  30.   dbms_output.put_line('after, l_1=' || l_1 || ', l_2=' || l_2 || ', l_3=' || l_3);  
  31. END;  
参考
http://www.cnblogs.com/xublogs/archive/2011/06/24/2292198.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30201626/viewspace-1813748/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: cursor和sys_refcursor
请登录后发表评论 登录
全部评论

注册时间:2015-04-11

  • 博文量
    43
  • 访问量
    44267