Subject [firebird-support]Curious IB vs FB in SP
Author Paul Hope
Hi



Have a curious thing in a stored procedure. The part below increments a
char(1) from '1' to '8' then down to '0'.



In IB 5.6 this works fine



Declare variable s char(1);



Get a value for s from a char(1) field



if (s is null) then s='1'; else

begin

if((s>='0')and(s<'9'))then s=cast(cast(s as integer)+1 as char(1));
else

if (s='9') then s='0';

end



In FB 1.5.0.4306 it fails with a arithmetic overflow/string truncation. A
select distinct from the table shows values from '0' to '8' and null.



Changing it to this it works



if (s is null) then s='1'; else

begin

i=cast(s as integer)+1;

if (i>8) then i=0;

s=cast(i as char(1));

end



Isn't really a problem but wondered if it hinted at a bug?



Regards

Paul





[Non-text portions of this message have been removed]