I have got the following UDF
drop function if exists getCurrency$$
create function getCurrency(dt datetime, x decimal(19,4), y decimal(19, 4))
returns decimal(10,4) reads sql data
begin
declare currencyval decimal(10,4);
/* Some conditions */
select case when dt = "2000-12-31" then 0 else round((x/y), 4) into currencyval;
return currencyval;
end$$
Sometimes this UDF throws Data truncation error.
I can resolve the issue but the before even that I want some information regarding the Decimal data type and the significance of 10, 4 in the parameters.
It would be good if you give some examples with the boundary conditions.
10, 4means 6 digits (integer part) before point and 4 after (fractional part).So the biggest possible number you can return is
999999.9999In your particular case it is not possible to say what values are boundary for
xand/ory, but you can check if the return value (currencyval) is out of-999999.9999 .. 999999.9999range.Btw, if you’re asking about
xandyinDECIMAL (x, y)records, then:x = 1..65y = 0..30 && y <= xReferences:
DECIMAL,NUMERIC