您好,登錄后才能下訂單哦!
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捕獲,而是繼續向外傳播。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。