"#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 'CREATE FUNCTION TavoliLiberi (dataora DATETIME) RETURN BOOL BEGIN DECLARE prese' at line 3" in this function:
DELIMITER $
DROP FUNCTION IF EXISTS TavoliLiberi;
CREATE FUNCTION TavoliLiberi (dataora DATETIME) RETURN BOOL
BEGIN
DECLARE presenti BOOL;
DECLARE numPrenotazioni INT;
DECLARE numTavoli INT;
SELECT COUNT(*) INTO numPrenotazioni
FROM Prenotazioni
WHERE DataOra = dataora;
SELECT COUNT(*) INTO numTavoli
FROM Tavoli;
IF (numPrenotazioni < numTavoli) THEN
SET presenti = TRUE;
ELSE
SET presenti = FALSE;
END IF;
RETURN presenti;
END $
DELIMITER ;
What's wrong?