Subject Re: [firebird-support] Re: NUMERIC(18,6) calculation problem
Author Luis Madaleno
Hi,

No. I mean I tried with both:

declare variable tmp NUMERIC(18,12);
declare variable tmp1 NUMERIC(18,6);
declare variable tmp2 NUMERIC(18,6);
begin
tmp1 = new.fld1;
tmp2 = new.fld2;
tmp = tmp1 * tmp2;
end;

and

declare variable tmp NUMERIC(18,12);
declare variable tmp1 NUMERIC(18,6);
declare variable tmp2 NUMERIC(18,6);
begin
tmp1 = new.fld1;
tmp2 = new.fld2;
new.fld3 = CAST((tmp1 * tmp2) AS NUMERIC(18,6));
end;

But both fail.



Adam wrote:
> --- In firebird-support@yahoogroups.com, Luis Madaleno <luis@...>
> wrote:
>
>> Hi,
>>
>> This seems not to work either:
>>
>> declare variable tmp NUMERIC(18,12);
>> declare variable tmp1 NUMERIC(18,6);
>> declare variable tmp2 NUMERIC(18,6);
>> begin
>> tmp1 = new.fld1;
>> tmp2 = new.fld2;
>> tmp = tmp1 * tmp2;
>>
>
> Did you mean here
>
> new.fld3 = CAST(tmp AS NUMERIC(18,6));
>
>
>> end;
>>
>
> If the problem is how Firebird handles intermediate results, and you
> are using the tmp field that is large enough to hold these results to
> get around this, then I assume tmp is what you meant to cast. You may
> also want to try it without the new.fld3 line to see whether 18,12 is
> large enough to fit the intermediate results.
>
> I don't usually need to do this sort of thing, so I can't really be
> of much more help.
>
> Adam
>
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>