首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >算术溢出错误-802

算术溢出错误-802
EN

Stack Overflow用户
提问于 2014-09-10 06:34:48
回答 2查看 167关注 0票数 3

嗨,有一个表,如果从一个过程中获取数据,这个过程可以正常工作,但是当试图插入数据时,我会得到一个算术错误,我不知道你是如何解决这个问题的。任何帮助都将不胜感激。

以下是程序:

代码语言:javascript
复制
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;

以下是insert语句:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-15 10:35:27

谢谢你的意见,你离问题不远了。过程允许描述为varchar(1000),而它插入的表允许描述为varchar(200),这导致溢出错误。

这里的解决方案是将目标表中的desciption字段更改为blob,或者增加描述的char大小,使其与使用alter语句的过程相匹配。

firebird sql:

代码语言:javascript
复制
alter table TBLREPORT_LEDGERCONTROL alter description type varchar(1000)
票数 0
EN

Stack Overflow用户

发布于 2014-09-11 12:03:46

我相信数字溢出意味着您正在尝试将5位数放入4位字段中。(即:不能将12345插入数值(4,0)列)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25758796

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档