Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

AmitPandey2604Jul 27 2019 — edited Jul 29 2019

when i am entering a large value for department_id I am getting error for the given code, i tried to create an exception handling for ORA-06502: PL/SQL: numeric or value error: number precision too large

it is non defined user error, is there anyway to handle this

-- create a exception handling program for this;           ORA-06502: PL/SQL: numeric or value error: number precision too large

-- enter value for &dno 444444444444444

declare

v_department_id departments.department_id%type:=&dno;

v_sum_sal number;

non_d_err exception;

pragma exception_init(non_d_err,-06502);

begin

select sum(salary) into v_sum_sal from employees where department_id=v_department_id;

     dbms_output.put_line('the sum of the salary is'||v_sum_sal);

     dbms_output.put_line(sql%rowcount);

    

exception

when non_d_err then

-- have a great day .....enjoy

     dbms_output.put_line('value for department id is larger than expected');

     dbms_output.put_line(sqlcode);

     dbms_output.put_line(sqlerrm);

end;

Comments
Post Details
Added on Jul 27 2019
12 comments
2,586 views