This Is A FineDay

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  93 随笔 :: 0 文章 :: 69 评论 :: 0 Trackbacks

--定义EXCEPTION
SET SERVEROUTPUT ON
DECLARE
       A exception;
BEGIN
      RAISE A;
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('EXCEPTION A!');
         WHEN OTHERS THEN
              ROLLBACK; 
                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');    
END;
--结果
--EXCEPTION A!

--EXCEPTION 001
SET SERVEROUTPUT ON
DECLARE
       A exception;
       B exception;
BEGIN  
     RAISE B;
       BEGIN
              RAISE A;
       EXCEPTION
                WHEN A THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION A!');
                WHEN B THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION B!');               
       END; 
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION A!');
         WHEN B THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!');  
         WHEN OTHERS THEN
         ROLLBACK; 
                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');  
END;
--结果
--OUT EXCEPTION B!

--EXCEPTION 002
SET SERVEROUTPUT ON
DECLARE
       A exception;
       B exception;
BEGIN  
       BEGIN
              RAISE A;
       EXCEPTION
                WHEN A THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION A!');
                WHEN B THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION B!');               
       END;
    RAISE B;
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION A!');
         WHEN B THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!');
         WHEN OTHERS THEN
         ROLLBACK; 
                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');     
END;
--结果
--IN EXCEPTION A!
--OUT EXCEPTION B!

--EXCEPTION 003
SET SERVEROUTPUT ON
DECLARE
       A exception;
       B exception;
BEGIN  
       BEGIN
              RAISE A;
       EXCEPTION
                WHEN B THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION B!');               
       END;
    RAISE B;
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION A!');
         WHEN B THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!'); 
         WHEN OTHERS THEN
         ROLLBACK; 
                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');    
END;
--结果
--OUT EXCEPTION A!

--EXCEPTION 004
SET SERVEROUTPUT ON
DECLARE
       A exception;
       B exception;
       C exception;
BEGIN 
   RAISE C;
       BEGIN
              RAISE A;
       EXCEPTION
                WHEN B THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION B!');               
       END;
    RAISE B;
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION A!');
         WHEN B THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!'); 
         WHEN OTHERS THEN
         ROLLBACK; 
                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');    
END;
--结果
--OTHERS EXCEPTION!

--EXCEPTION 005
SET SERVEROUTPUT ON
DECLARE
       A exception;
       B exception;
       C exception;
BEGIN 
       BEGIN
              RAISE A;
       EXCEPTION
                WHEN A THEN
                  RAISE C;
                WHEN B THEN
                     DBMS_OUTPUT.put_line('IN EXCEPTION B!');               
       END;
    RAISE B;
EXCEPTION
         WHEN A THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!');
         WHEN B THEN
                  DBMS_OUTPUT.put_line('OUT EXCEPTION B!'); 
         WHEN OTHERS THEN
         ROLLBACK; 

                    DBMS_OUTPUT.put_line('OTHERS EXCEPTION!');    
END;
--结果:
--OTHERS EXCEPTION!

posted on 2007-03-09 16:40 Peter Pan 阅读(882) 评论(0)  编辑  收藏 所属分类: DB

只有注册用户登录后才能发表评论。


网站导航: