I have a problema, transofrming a sql server code into mysql. I can't solve the return problem. Error is: [Err] 1415 - Not allowed to return a result set from a function. I tried use select into, but I can't solve it. Any ideas?
CREATE FUNCTION udf_NORMDIST (v FLOAT,
mean FLOAT,
sigma FLOAT,
cummulative int)
RETURNS NUMERIC(28,8)
BEGIN
SELECT @x = (v-mean)/sigma;
IF (cummulative = 1) then
SELECT @z = abs(@x)/sqrt(2.0);
SELECT @t = 1.0/(1.0+0.5*@z);
SELECT @ans = @t*exp(-@z*@z-1.26551223+@t*(1.00002368+@t*(0.37409196+@t*(0.09678418+@t*(-0.18628806+@t*(0.27886807+@t*(-1.13520398+@t*(1.48851587+@t*(-0.82215223+@t*0.17087277)))))))))/2.0;
IF @x <= 0 then
return @ans;
ELSE
return 1-@ans;
END if;
ELSE
return exp(-@x*@x/2.0)/sqrt(2.0*3.14159265358979);
END if;
END