Subject Re: [firebird-support] About UDF's problem
Author Helen Borrie
At 09:59 PM 14/08/2005 +0800, Jinyang wrote:
> I want to convert 11.234 to 11.23(or 22.456 to 22.46) in stored
> procedure.I want to use the udf.First,I don't find which function is good.
>Second, I use round func,as the example,the result is null,why?

Perhaps the number is a floating point number. IBUDF's round() function
takes a scaled numeric. But round() does not truncate numbers, it removes
the decimal part of a scaled numeric and returns an integer.

>example in stored procedure:
>select sum(round(Field1))
>from table1,
>the result is null,but if:
>select sum(Field1)
>from table1,
>result is the value in talbe.

You don't need a UDF. Just use a CAST() expression:

select cast(sum(Field1) as numeric(9,2)) as Total
from table1