Subject Re: [firebird-support] Problem with division
Author Helen Borrie
At 09:36 PM 4/02/2004 -0800, you wrote:
>Greetings,
>I'm using FB 1.03 and have the following SP:
>
>create procedure sp_test_pct
>returns (Pct Numeric(8,6))
>as
>begin
> Pct = Cast((29920 / 106532) as Numeric(8,6) );
> suspend;
>end
>
>Right now, Pct is returned as all zeros and it should be something like:
>0.280854
>
>I've tried w/out the casting as well with the same zero results.
>
>Any ideas would be GREATLY appreciated.


Integer/integer division returns an integer in ODS 10, so the result is
"correct" by SQL rules. If you want a decimal portion in the result, you
have to include it in one or both of the operands, e.g.
Pct = Cast(( (1.000 * 29920) / (1.000 * 106532)) as Numeric(8,6) );

/hb