简体   繁体   中英

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

I'm trying to run the following insert command in Oracle SQL Developer:

insert into work_comp_rates (company_id, work_comp_rt)
values ('101', 0.11);

Which gives me this error: "ORA-06502: PL/SQL: numeric or value error: number precision too large"

There is a trigger attached:

create or replace 
TRIGGER APPS.work_codes_trig
before insert or update ON APPS.WORK_COMP_RATES for each row
begin
  if inserting then
    if :NEW.RID is null then
      :NEW.RID := it_api.gen_pk;
    end if;
    :NEW.CREATED_ON := sysdate;
  end if;
  if updating then
    :NEW.MODIFIED_ON := sysdate;
  end if;
end;

If I replace

:NEW.RID := it_api.gen_pk; 

with

:NEW.RID := 599;

the insert statement works.

IT_API Body:

create or replace
package body it_api
as
-- generates and returns unique number used for primary key values
function gen_pk
return number
is
l_pk number := 0;
begin
for c1 in (
select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') pk
from dual )
loop
l_pk := c1.pk;
exit;
end loop;
return l_pk;
end gen_pk;
end it_api;

I don't know Oracle very well and that script was written by somebody else. So any help is appreciated!

I created a sequence rate_seq that increments values by 1 and replaced

:NEW.RID := it_api.gen_pk; 

with

select rate_seq.nextval
into :new.rid
from dual;

That fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM