MySQL Forums
Forum List  »  Stored Procedures

Re: MySQL: Stored function not accepting null from view field
Posted by: Roger Palacios
Date: December 12, 2013 03:49PM

Here is the function code:

CREATE DEFINER=`##############`
FUNCTION `nivel_color_id`(`escala` VARCHAR(16), `valor` FLOAT) RETURNS int(11)
BEGIN
DECLARE nivel INT(11) Default 0;

if (not valor is null) then
select id_nivel into nivel
from niveles_colores nc
where ((valor = 0 and nc.valor_minimo = valor)
or (valor > nc.valor_minimo
and valor <= nc.valor_maximo))
and nombre_escala = escala;
else
set nivel = -1;
end if;
return nivel;
END


==============================

If I do the call directly: SELECT nivel_color_id('Cumplimiento', null); It returns -1, that is the expected value.

With not-null values it works ok.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: MySQL: Stored function not accepting null from view field
1124
December 12, 2013 03:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.