Arithmetic overflow error -802

Hi there is a table that gets, if data is from a procedure, the procedure works fine, but when I try to insert that data, I get an arithmetic error and I'm not sure how you are fixing it. any help would be appreciated.

here is the procedure:

SET TERM ^ ;
CREATE PROCEDURE REPORT_CONTROLLEDGER (
  DATESTART Date,
  DATEEND Date,
  INCOMPANYID Integer )
RETURNS (
  GLCODE Varchar(8),
  DATUM Date,
  PERIOD Varchar(2),
  SOURCE Varchar(30),
  REFERENCENO Varchar(200),
  GLDESCRIPTION Varchar(200),
  DESCRIPTION Varchar(1000),
  DR Numeric(10,2),
  CR Numeric(10,2),
  COSTCODE Varchar(8),
  BALANCE Numeric(10,2),
  COMPANYID Integer )
AS
  declare lastglcode varchar (8);
  declare grouptype integer;
  declare tglcode varchar (8);
  declare tdatum date;
  declare tperiod varchar (2);
  declare tsource varchar (30);
  declare treferenceno varchar (200);
  declare tdescription varchar (1000);
  declare tdr numeric (10,2);
  declare tcr numeric (10,2);
  declare tcostcode varchar (8);


begin
  lastglcode = '';
  balance = 0;
  companyid = incompanyid;
  for select glcode, datum, period, source, referenceno, description, dr, cr, costcode from controlledger where companyid = :companyid and datum between :datestart and :dateend order by GLCODE, datum, id  
  into tglcode, tdatum, tperiod, tsource, treferenceno, tdescription, tdr, tcr, tcostcode  
do
begin
  select description from subcode where glcode = :tglcode and companyid = :companyid into :gldescription;
  if (lastglcode <> tglcode) then
  begin
    select grouptype from subcode where glcode = :tglcode and companyid = :companyid into :grouptype;

  if (grouptype = 1) then
  begin
    select sum (dr - cr) from CONTROLLEDGER where companyid = :companyid and glcode = :tglcode and datum < :datestart into :balance;  
    if (balance is null) then balance = 0;
    glcode = tglcode;
    referenceno = null;
    description = 'Balance Brought Forward';
    cr = null;
    dr = null;
    source = null;
    costcode = null;
    datum = null;
    period = null; -- added by Andre
    suspend;  

  end 
    else
  begin
    balance = 0;
  end 
  lastglcode = tglcode; 
end
glcode = tglcode;
referenceno = treferenceno;
description = tdescription;
cr = tcr;
dr = tdr;
source = tsource;
costcode = tcostcode;
datum = tdatum;
period = tperiod; -- added by Andre

balance = balance + (tdr - tcr);   
suspend;
end

end^
SET TERM ; ^

GRANT EXECUTE
 ON PROCEDURE REPORT_CONTROLLEDGER TO  SYSDBA;

      

here is the insert statement:

insert into tblreport_ledgercontrol select cast('03/01/2013' as date),
             cast('04/30/2014' as date),
             iif(cl.DATUM is null, 'now', cl.DATUM)as datum,
             'Detailed Ledger Report from 0000.000 to 9999.999 for period 01/03/2013 to 30/04/2014' as reporttitle,
               'ubuntu' as processedby,
                iif(cl.GLCODE is null, 00, cl.GLCODE)as glcode,
                iif(cl.PERIOD is null, 0 , cl.PERIOD)as period,
                iif(cl.SOURCE is null, 'n/a', cl.SOURCE)as source,
                iif(cl.REFERENCENO is null, 'n/a', cl.REFERENCENO)as referenceno,
                cl.GLDESCRIPTION,
                cl.DESCRIPTION,
                iif(cl.dr is null, 0, cl.dr)as dr,
                iif(cl.cr is null, 0, cl.cr)as cr,
                iif(cl.COSTCODE is null, 00, cl.COSTCODE)as costcode,
                cl.BALANCE,
                cl.COMPANYID,
                955,
                gen_id (GEN_TBLREPORT_LEDGERCONTROL_ID, 1)
        from report_controlledger ('03/01/2013','04/30/2014', 676) cl

      

+3


source to share


2 answers


Thanks for your input, you were not far from what was wrong. The procedure allowed the declaration to be varchar (1000), while the table into which it was inserted allowed the declaration to be varchar (200) and this caused an overflow error.

The gist here was to change the desciption field in the target table to blob, or to increase the size of the char description as described in the procedure using the alter statement.



firebird sql:

alter table TBLREPORT_LEDGERCONTROL alter description type varchar(1000)

      

0


source


I believe numeric overflow means that you are trying to fit 5 digits in a 4 digit field. (ie: cannot insert 12345 into numeric column (4,0))



0


source







All Articles