Codice: Seleziona tutto
CREATE FUNCTION NumUtenti() RETURNS INT
BEGIN
DECLARE conta INT;
SELECT COUNT(*) INTO conta FROM Utenti;
RETURN conta
END
CREATE TRIGGER MaxUsers
BEFORE INSERT ON Utenti FOR EACH ROW
BEGIN
IF(NumUtenti() >= 7)
THEN INSERT INTO Utenti VALUES (NULL,'pluto')
END IF;
END;Codice: Seleziona tutto
mysql> source trigger.sql;
ERROR 1064 (42000): 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 '' at line 3
ERROR 1327 (42000): Undeclared variable: conta
ERROR 1064 (42000): 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 'RETURN conta
END
CREATE TRIGGER MaxUsers
BEFORE INSERT ON Utenti FOR EACH ROW
' at line 1
ERROR 1064 (42000): 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 'END' at line 1
Grazie mille.
Buona Giornata