Tag Archives: Increased the length of datatype

ORA-06502: PL/SQL: numeric or value error: number precision too large

ORA-06502: PL/SQL: numeric or value error: number precision too large

Number datatype is declared less then the value used in it for insert caused the error:

Error
V_NUMBER variable length is declared as 2 and we tried to insert into 3 digit number then it will generate the error.

Declare
v_number number(2);
BEGIN
v_number := 100;
END;
/

OUTPUT
Declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at line 4

Solution:
Increased the length of datatype declared in declare block of PL/SQL.

Declare
v_number number(5);
BEGIN
v_number := 100;
dbms_output.put_line(v_number);
END;
/

OUTPUT
100

PL/SQL procedure successfully completed.