outofscope.sql

来自「介绍Oracle PL SQL编程」· SQL 代码 · 共 48 行

SQL
48
字号
/*
 * OutOfScope.sql
 * Chapter 7, Oracle10g PL/SQL Programming
 * by Ron Hardman, Mike McLaughlin, and Scott Urman
 *
 * This script demonstrates the scope of exceptions.
 */

BEGIN
  DECLARE
    e_UserDefinedException EXCEPTION;
  BEGIN
    RAISE e_UserDefinedException;
  END;
EXCEPTION
  /* e_UserDefinedException is out of scope here - can only be
     handled by an OTHERS handler */
  WHEN OTHERS THEN
    /* Just re-raise the exception, which will be propagated to the
       calling environment */
    RAISE;
END;
/

CREATE OR REPLACE PACKAGE Globals AS
/* This package contains global declarations. Objects declared here will 
   be visible via qualified references for any other blocks or procedures.
   Note that this package does not have a package body. */

  /* A user-defined exception. */
  e_UserDefinedException EXCEPTION;
END Globals;
/

BEGIN
  BEGIN
    RAISE Globals.e_UserDefinedException;
  END;
EXCEPTION
  /* Since e_UserDefinedException is still visible, we can handle it 
     explicitly */
  WHEN Globals.e_UserDefinedException THEN
    /* Just re-raise the exception, which will be propagated to the
       calling environment */
    RAISE;
END;
/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?