1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| delimiter |
CREATE FUNCTION DETERMINE1234(s VARCHAR(2000)) RETURNS int(2)
DETERMINISTIC
BEGIN
DECLARE open INT;
DECLARE close INT;
DECLARE someLimit INT;
DECLARE cpt int;
DECLARE cs int;
DECLARE cm int;
DECLARE co int;
DECLARE str VARCHAR(255);
DECLARE toFind VARCHAR(2000);
SET open = 1;
SET close = 1;
SET cpt=0;
SET cs=0;
SET cm=0;
SET co=0;
SET toFind = s ;
SET someLimit = 5;
SET str ='';
WHILE close > 0 and open > 0 and someLimit > 0 DO
SET someLimit = someLimit -1;
SET toFind = SUBSTRING(toFind,open);
SET close = locate(',',toFind);
IF close > 2 THEN
SET str =SUBSTRING(toFind,2,close-2);
IF (Select id_equipe from intervenant where nom_intervenant=str='Deploiement Radio') OR
(Select id_equipe from intervenant where nom_intervenant=str='Optimisation Huawei')OR
(Select id_equipe from intervenant where nom_intervenant=str='Optimisation NSN') OR
(Select id_equipe from intervenant where nom_intervenant=str='Support BSS Nord') OR
(Select id_equipe from intervenant where nom_intervenant=str='Support BSS Sud') THEN SET co=1;
END IF;
IF (Select id_equipe from intervenant where nom_intervenant=str='QDF') OR
(Select id_equipe from intervenant where nom_intervenant=str='Supervision Back Office') THEN SET cs=1;
END IF;
IF (Select id_equipe from intervenant where nom_intervenant=str='Maintenance') THEN SET cm=1;
END IF;
SET toFind = SUBSTRING(toFind,close);
END IF;
END WHILE;
SET cpt=co+cs+cm;
return cpt;
END |
delimiter; |