Problème d'execution d'une fonction..
J'ai créé une fonction qui pprends 4 arguments char et retourner un char:
Citation:
CREATE FUNCTION test(arg1 char(255), arg2 char(255), arg3 char(255), arg4 char(255))
RETURNS char(255)
BEGIN
DECLARE val1, val2, val3, val4
INT;
SET val1 =
ASCII(arg1);
SET val2 =
ASCII(arg2);
SET val3 =
ASCII(arg3);
SET val4 =
ASCII(arg4);
IF (0 NOT IN (val1,val2,val3,val4)) AND (32 NOT IN (val1,val2,val3,val4)) THEN
RETURN CONCAT(CONCAT(arg1 , ' ', arg2),' - ',CONCAT(arg3 , ' ', arg4));
ELSEIF (0 NOT IN (val1,val2)) AND (32 NOT IN (val1,val2)) THEN
RETURN CONCAT(arg1 , ' ', arg2);
ELSE
RETURN 'rien';
END IF;
END;
La condition IF verifie si les champs sont vides ou contiennent un simple éspace...
avec la requète test suivante, tous marche bien:
Citation:
select test('18','ans','20','years');
==>18 ans - 20 years
mais quand je l'applique à mes champs de table, c'est le dernier else qui est exècuté bien que les champs contiennent les memes valeurs de la requete test:
Citation:
select test(tab.year1, tab.str1, tab.year2, tab.str2) from tab where tab.year1='18';
==> rien
Je ne comprends pas ce qui cloche :? ?