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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.