Subject Re: [IBO] IBO detect a wrong numerics field
Author Helen Borrie
At 07:40 PM 14/12/2003 +0800, you wrote:
>I have a trigger which I made, here is the code.
>
>CREATE TRIGGER "counter_AI0" FOR "counter"
>ACTIVE AFTER INSERT POSITION 0
>AS
>begin
> /* if the payment is an advance then add a credit */
> if (new."Mode" = 'ADV') then
> insert into "suppliercredit"(ID, "PaymentID", "Amount", "Status",
>"Type")
> values (gen_id("gen_suppliercredit",1), new.ID, new."Amount", 'ACT',
>'ADV');
>
>end
>
>The problem is that on the suppliercredit table, the amount field has no
>value at all. I don't the amount field is always null. The amount field
>of both table are both numeric(15,2). I also check the value of the
>amount field in counter table there is no problem at all, but I just
>can't figure it out why the Amount on suppliercredit is always null.
>
>While waiting for answer Iam still trying to work on this. I see the in
>IBO, it say that my "Amount" field is numerics(18,2), but actually it is
>numeric(15,2). Could this be the problem why my trigger doesn't work? Why
>is it that the IBO detect wrong way?

It doesn't detect it the wrong way. It receives the column attribute as
its SQLType. In Firebird, all fixed numerics with a precision higher than
10 have a precision of 18. An "underflow" - passing a value of lower
precision than the column declaration - does not cause problems. However,
on the server, you would get an exception passing a numeric that
*overflows* the declared precision. In your applications, you need to take
care of overflows to avoid this exception occurring on the server.

But there is no exception occurring here. I think you have Before Insert
trigger in one or other of these tables that is messing up your "Amount"
value and making it null, or you are doing something with the input value
in your application code that is causing null to be posted.

Please don't cross-post.

Helen