この関数をmysqlに書き込もうとしていますが、次のエラーが発生しています:
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF Per='hour' THEN SET t=Price ; END IF;
IF Per='day' THEN SET t=Price/24; END ' at line 8
DELIMITER$$
CREATE FUNCTION PricePerHour (Price REAL, Per VARCHAR(5))
RETURNS REAL
DETERMINISTIC
BEGIN
DECLARE t REAL;
IF Price IS NOT NULL AND Per IS NOT NULL
IF Per='hour' THEN SET t=Price ; END IF;
IF Per='day' THEN SET t=Price/24; END IF;
IF Per='week' THEN SET t=Price/7/24; END IF;
IF Per='month' THEN SET t=Price/30/24; END IF;
IF Per='year' THEN SET t=Price/365/30/24; END IF;
RETURN t;
END IF;
END $$
DELIMITER;
どんな助けでも感謝されるべきです。事前にサンクス。