2011-11-21 未捕获异常
短信预约 -IT技能 免费直播动态提醒
http://www.itpub.net/thread-1499223-17-1.html
167楼
下列哪些选项在执行之后会导致未捕获的异常:
ORA-06502: PL/SQL: numeric or value error: number precision too large
(A)
DECLARE
l_number NUMBER (2) := 100;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
/
SQL> DECLARE
2 l_number NUMBER (2) := 100;
3 BEGIN
4 DBMS_OUTPUT.put_line (l_number);
5 END;
6 /
DECLARE
l_number NUMBER (2) := 100;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
ORA-06502: PL/SQL: 数字或值错误 : 数值精度太高
ORA-06512: 在 line 2
SQL>
(B)
DECLARE
l_number NUMBER (2) := 100;
BEGIN
DBMS_OUTPUT.put_line (l_number);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('ERROR');
END;
/
SQL> DECLARE
2 l_number NUMBER (2) := 100;
3 BEGIN
4 DBMS_OUTPUT.put_line (l_number);
5 EXCEPTION
6 WHEN OTHERS
7 THEN
8 DBMS_OUTPUT.put_line ('ERROR');
9 END;
10 /
DECLARE
l_number NUMBER (2) := 100;
BEGIN
DBMS_OUTPUT.put_line (l_number);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('ERROR');
END;
ORA-06502: PL/SQL: 数字或值错误 : 数值精度太高
ORA-06512: 在 line 2
SQL>
(C)
CREATE OR REPLACE PACKAGE plch_pkg
IS
FUNCTION get_number
RETURN NUMBER;
END;
/
CREATE OR REPLACE PACKAGE BODY plch_pkg
IS
g_date DATE;
g_number NUMBER (2) := 100;
FUNCTION get_number
RETURN NUMBER
IS
BEGIN
RETURN g_number;
END;
BEGIN
g_date := SYSDATE;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('ERROR');
END;
/
DECLARE
l_number NUMBER (2) := plch_pkg.get_number;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
/
SQL> CREATE OR REPLACE PACKAGE plch_pkg
2 IS
3 FUNCTION get_number
4 RETURN NUMBER;
5 END;
6 /
Package created
SQL> CREATE OR REPLACE PACKAGE BODY plch_pkg
2 IS
3 g_date DATE;
4 g_number NUMBER (2) := 100;
5
6 FUNCTION get_number
7 RETURN NUMBER
8 IS
9 BEGIN
10 RETURN g_number;
11 END;
12 BEGIN
13 g_date := SYSDATE;
14 EXCEPTION
15 WHEN OTHERS
16 THEN
17 DBMS_OUTPUT.put_line ('ERROR');
18 END;
19 /
Package body created
SQL> DECLARE
2 l_number NUMBER (2) := plch_pkg.get_number;
3 BEGIN
4 DBMS_OUTPUT.put_line (l_number);
5 END;
6 /
DECLARE
l_number NUMBER (2) := plch_pkg.get_number;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
ORA-06502: PL/SQL: 数字或值错误 : 数值精度太高
ORA-06512: 在 "YOGA.PLCH_PKG", line 4
ORA-06512: 在 line 2
SQL>
(D)
CREATE OR REPLACE PACKAGE plch_pkg
IS
g_number NUMBER (2) := 100;
END;
/
DECLARE
l_number NUMBER (2) := plch_pkg.g_number;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
/
SQL> CREATE OR REPLACE PACKAGE plch_pkg
2 IS
3 g_number NUMBER (2) := 100;
4 END;
5 /
Package created
SQL> DECLARE
2 l_number NUMBER (2) := plch_pkg.g_number;
3 BEGIN
4 DBMS_OUTPUT.put_line (l_number);
5 END;
6 /
DECLARE
l_number NUMBER (2) := plch_pkg.g_number;
BEGIN
DBMS_OUTPUT.put_line (l_number);
END;
ORA-06502: PL/SQL: 数字或值错误 : 数值精度太高
ORA-06512: 在 "YOGA.PLCH_PKG", line 3
ORA-06512: 在 line 4
SQL>
答案在172楼
2011-11-21 答案:ABCD
如果异常发生在BEGIN之前,比如DECLARE部分或PACKAGE的变量初始化部分,那么这个异常就不会被当前块的EXCEPTION捕获,而是继续向外传播。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341