私はmysql関数を必要としていますが、
このmysql関数が毎回同じ値を返すたびに同じ値を返します.つまり、S_Start_ToBeStarted (最初のIfの値)
-- colorA
DELIMITER $$
DROP FUNCTION IF EXISTS `colorA`$$
CREATE FUNCTION `colorA`(
Appf VARCHAR(3),
Start_Datef DATETIME,
PDCf DATETIME
) RETURNS INT
DETERMINISTIC
BEGIN
DECLARE finalcolor INT DEFAULT 0;
IF Appf = 'Yes' & IFNULL(Start_Datef, 'NULL' = 'NULL' & sysdate() <= PDCf
THEN SET finalcolor = (SELECT `PP_Colors`.`S_Start_ToBeStarted` FROM `SCR_Sap`.`PP_Colors` LIMIT 1);
ELSE IF Appf = 'Yes' & IFNULL(Start_Datef, 'NULL') = 'NULL' & sysdate() > PDCf
THEN SET finalcolor = (SELECT `PP_Colors`.`S_Start_Error` FROM `SCR_Sap`.`PP_Colors` LIMIT 1);
ELSE IF Appf = 'Yes' & IFNULL(Start_Datef, 'NULL') != 'NULL' & sysdate() <= PDCf
THEN SET finalcolor = (SELECT `PP_Colors`.`S_Start_Ok` FROM `SCR_Sap`.`PP_Colors` LIMIT 1);
ELSE IF Appf = 'Yes' & IFNULL(Start_Datef, 'NULL') != 'NULL' & sysdate() > PDCf
THEN SET finalcolor = (SELECT `PP_Colors`.`S_Start_LateStarted` FROM `SCR_Sap`.`PP_Colors` LIMIT 1);
ELSE SET finalcolor = (SELECT `PP_Colors`.`S_NotApplicable` FROM `SCR_Sap`.`PP_Colors` LIMIT 1);
END IF;
END IF;
END IF;
END IF;
RETURN finalcolor;
END$$
DELIMITER ;