Subject Re: [firebird-support] NUMERIC(18,6) calculation problem
Author Ivan Prenosil
> I have this weird calculation problem with NUMERIC(16,6) fields.
>
> >>>>>>>>>>>>>>>>>>
> Error Message:
> ----------------------------------------
> Unsuccessful execution caused by system error that does not preclude
> successful execution of subsequent statements.
> Integer overflow. The result of an integer operation caused the most
> significant bit of the result to carry.
> <<<<<<<<<<<<<<<<<<
>
> This shows up in a trigger with this code:
> CREATE TRIGGER OM_BIU1 FOR O_MOVS
> ACTIVE BEFORE INSERT OR UPDATE POSITION 1
> AS
> /* fld1 is NUMERIC(18,6); */
> /* fld2 is NUMERIC(18,6); */
> /* fld3 is NUMERIC(18,6); */
> begin
> new.fld3 = new.fld1 * new.fld2;
> /* fld2 is always equal to 1 */
> end
>
> But this only happens when fld1 is bigger than 9 200 000.
> If I enter 9 000 000 in fld1, it works.

It is correct. Result of multiplication of two NUMERIC(18,6) values
is NUMERIC(18,12), which means the biggest resulting number is
9223372.036854775807


> Unsuccessful execution caused by system error that does not preclude
> successful execution of subsequent statements.

This is weird, seems like you have another problem ...

Ivan