2017-03-01 28 views
-5

它应该是0,但我得到它在Java它出来:2147483647为什么我的代码得到最大的int 2147483647不是零?

我测试在Navicat:

enter image description here

的产品代码是这样的:

BEGIN 
declare itype int(1) default 0;  
declare zdAreaCode varchar(20) ; 
declare icount int(8) default 0; 
declare iicount int(8) default 0; 
declare i int ; 
/*declare iserror int(1) default 0; 
declare continue HANDLER for SQLEXCEPTION set iserror=1;*/ 
set out_a=60; 
set out_b=35; 
set out_c=72; 
set out_d=3; 
set out_e=''; 
set out_f=''; 
set out_g=''; 
set out_h=''; 
set out_i='0100001000'; 
set out_j='10'; 
set out_k=90; 
set out_l=''; 
set out_m=0; 
set out_n=0; 
set out_o=''; 
insert into D09 select in_a,in_b,in_c,in_d,in_e,in_f,in_g,in_h,in_i,in_j,in_k,in_l,in_m,in_o,0,in_n,date_format(now(),'%Y%m%d%H%i%s'); 

select count(*) into icount from X02 where X0201=1 and X0202=in_a; 
if icount=0 then 
    insert into X02 select 1,in_a,'',date_format(now(),'%Y%m%d%H%i%s') ; 
else 
    update X02 set X0204=date_format(now(),'%Y%m%d%H%i%s') where X0201=1 and X0202=in_a; 
end if; 

select count(*) into icount from X04 where X0401=in_a and X0407=0;/*系统参数*/ 
if icount>0 THEN 
select X0403,X0405 into zdAreaCode,itype from X04 where X0401=in_a and X0407=0; 
set i=0; 

    while (i<3) and (iicount=0) DO 
    select count(*) into iicount from M02 where substr(M0201,1,6-i*2)=substr(zdAreaCode,1,6-i*2); 
    if iicount=0 THEN 
     set i=i+1; 
    end if; 
    end while; 
    if iicount>0 THEN 
    select M0204,M0205,M0206,M0208,M0209,M0211,M0212 into out_a,out_b,out_c,out_d,out_i,out_j,out_k from M02 
    where substr(M0201,1,6-i*2)=substr(zdAreaCode,1,6-i*2); 
    end if; 
    if itype=0 THEN /*养老金*/ 
    set i=0; 
    set iicount=0; 
    while (i<3) and (iicount=0) DO 
    select count(*) into iicount from E01 where substr(E0101,1,6-i*2)=substr(zdAreaCode,1,6-i*2); 
    if iicount=0 THEN 
     set i=i+1; 
    end if; 
    end while; 
    if iicount>0 THEN 
    select E0102,E0103,E0104,E0105 into out_e,out_f,out_g,out_h from E01 where substr(E0101,1,6-i*2)=substr(zdAreaCode,1,6-i*2); 
    end if; 
    end if; 
    select count(*) into iicount from R06 where R0601=in_a;/*设备参数*/ 
    if iicount>0 THEN 
    select R0603,R0604,R0602 into out_l,out_m,out_n from R06 where R0601=in_a; 
    end if; 
    select count(*) into icount from R05 where R0501=1 and R0504=in_a; 
    if icount>0 then 
    select distinct R0508 into out_o from R05 where R0501=1 and R0504=in_a; 
    ELSE 
    set out_o=''; 
    end if; 

end if; 
END 

测试代码如下:

call P_A_ParamInit("liaomalin", "P1111", "liaomalin", "0", "0", "0", "0", "0", "10", "1.0", "1.0", "0", "06DD501FF80811E69414FA163E59CFD5", "20170301111111", "511321199001031598", @a, @b, @c, @d, @e, @f, @g, @h, @i, @j, @k, @l, @m, @n, @o); 
SELECT @a, @b, @c, @d, @e, @f, @g, @h, @i, @j, @k, @l, @m, @n, @o; 

应该0

但在我的代码:

resultmap.put("c14", outParam_paraInit.get(28)); // get the `m` 

enter image description here

你看,它变成2147483647,最大的INT数。 为什么它不是0

+0

请张贴代码以及 –

回答

1

整数由4个字节组成,如果这些字节的所有位都设置为1的,然后这个数字是2147483647。

编辑二进制equivelent:

由于加入你的代码我并不聪明,看起来你正在从代码中获得一些意想不到的结果,但是他的代码只是一些神秘的变量名称,并不能真正解释你的目标。

编写的代码和问题的性质使得很难确定逻辑是否有问题,所以我倾向于用调试器来说明它的步骤,并看看在每一步中你有什么值。

+0

,如何获取int(0)?或者我怎样才能转换回0? – lme

+0

不知道,你的问题实际上没有意义,我的回答只是解释你所看到的价值。你需要发布产生这个输出的代码。 – War

+0

我已经发布了我的作品代码,谢谢。 – lme

相关问题