2011-11-21未捕获异常-创新互联
/tupian/20230522/thread-1499223-17-1.html
成都创新互联公司主要从事网站建设、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务高坪,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575167楼
下列哪些选项在执行之后会导致未捕获的异常:
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捕获,而是继续向外传播。
网页题目:2011-11-21未捕获异常-创新互联
网页路径:http://ybzwz.com/article/jhpsh.html