[20180928]ora-01426(补充).txt
[20180928]ora-01426(补充).txt
--//链接:http://www.itpub.net/thread-2105458-1-1.html
--//做一点点必要的补充:
1.环境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
2.我前面提到只要运算超出2^31就会溢出.
--//这里面的运算没有变量的情况.再做一个例子说明:
DECLARE
L_NUMBER number;
a number;
BEGIN
a := 1;
L_NUMBER := a * 1024 * 1024 * 1024 * 1024;
DBMS_OUTPUT.PUT_LINE(L_NUMBER);
L_NUMBER := 1024 * 1024 * 1024 * 1024;
DBMS_OUTPUT.PUT_LINE(L_NUMBER);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
dbms_output.put_line( dbms_utility.format_error_backtrace);
END;
/
--//执行如下:
SCOTT@test01p> DECLARE
2 L_NUMBER number;
3 a number;
4 BEGIN
5 a := 1;
6
7 L_NUMBER := a * 1024 * 1024 * 1024 * 1024;
8 DBMS_OUTPUT.PUT_LINE(L_NUMBER);
9
10 L_NUMBER := 1024 * 1024 * 1024 * 1024;
11 DBMS_OUTPUT.PUT_LINE(L_NUMBER);
12
13
14 EXCEPTION
15 WHEN OTHERS THEN
16 dbms_output.put_line(sqlerrm);
17 dbms_output.put_line( dbms_utility.format_error_backtrace);
18 END;
19 /
1099511627776
ORA-01426: numeric overflow
ORA-06512: at line 10
PL/SQL procedure successfully completed.
--//第1个赋值左边有变量存在,所以正常. 而第2个全部是常量,超出2^31报错.