为什么我的代码得到最大的int 2147483647不为零?

时间:2017-03-01 08:46:00

标签: java sql-server tsql

它应该是0,但我在java中得到它: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

1 个答案:

答案 0 :(得分:1)

整数由4个字节组成,如果这些字节中的所有位都设置为1,那么该数字是2147483647的二进制等价。

编辑:

由于添加了你的代码我不是更聪明,似乎你从代码中得到了一些意想不到的结果,但他的代码只是一堆神秘的变量名,并没有真正解释你的目标。 / p>

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