Tuesday, March 3, 2015

ORA-01426: numeric overflow (Control numeric overflow error in PL/SQL)

SQL> set serveroutput on;
SQL> DECLARE
  2          V_INDEX_NUMBER NUMBER(14);
  3      TYPE REC_ACCOUNT_BAL IS RECORD
  4          (
  5          ACCOUNT_NUMBER NUMBER(14),
  6          ACCOUNT_BALANCE NUMBER(18,3)
  7          );
  8
  9      TYPE TT_ACCOUNT_BAL IS TABLE OF REC_ACCOUNT_BAL INDEX BY PLS_INTEGER;
 10          T_ACCOUNT_BAL TT_ACCOUNT_BAL;
 11  BEGIN
 12      V_INDEX_NUMBER:=1000100300012;
 13      T_ACCOUNT_BAL(V_INDEX_NUMBER).ACCOUNT_BALANCE:=5000.00;
 14      DBMS_OUTPUT.PUT_LINE(T_ACCOUNT_BAL(V_INDEX_NUMBER).ACCOUNT_BALANCE);
 15  END;
 16  /
DECLARE
*
ERROR at line 1:
ORA-01426: numeric overflow
ORA-06512: at line 13


SQL> DECLARE
  2          V_INDEX_NUMBER NUMBER(14);
  3      TYPE REC_ACCOUNT_BAL IS RECORD
  4          (
  5          ACCOUNT_NUMBER NUMBER(14),
  6          ACCOUNT_BALANCE NUMBER(18,3)
  7          );
  8
  9      TYPE TT_ACCOUNT_BAL IS TABLE OF REC_ACCOUNT_BAL INDEX BY VARCHAR2(14);
 10          T_ACCOUNT_BAL TT_ACCOUNT_BAL;
 11  BEGIN
 12      V_INDEX_NUMBER:=1000100300012;
 13      T_ACCOUNT_BAL(V_INDEX_NUMBER).ACCOUNT_BALANCE:=5000.00;
 14      DBMS_OUTPUT.PUT_LINE(T_ACCOUNT_BAL(V_INDEX_NUMBER).ACCOUNT_BALANCE);
 15  END;
 16  /
5000

PL/SQL procedure successfully completed.

SQL>

No comments:

Post a Comment