salve, cercando di creare delle stored procedure in mysql , ma continuo ad avereun messaggio d'errore e non riesco a capire il perché?vi sarò grato se mi aiutate.
questo il codice
DELIMITER $$
CREATE PROCEDURE Disponibilita(IN prod INT, IN quant INT, INOUT torna INT)
BEGIN
DECLARE varq INT;
DECLARE crs CURSOR FOR SELECT quantita FROM magazzino WHERE id_prodotto = prod;
OPEN crs;
FETCH crs INTO varq;
IF var >= quant THEN SET torna = 1;
ELSE SET torna = 0;
END IF;
CLOSE crs;
END $$
è questo l'errore
#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 '$$' at line 20
anche nell'altra funzione
CREATE FUNCTION `Dim_quant`(prod int, quant int) RETURNS int
BEGIN
DECLARE orig int;
DECLARE torna int;
DECLARE cursore CURSOR FOR SELECT quantita FROM magazzino WHERE id_prodotto = prod;
OPEN cursore;
FETCH cursore INTO orig;
IF orig >= quant THEN
orig = orig – quant;
UPDATE magazzino SET quantita = orig WHERE id_prodotto = prod;
ELSE SET torna = 0;
END IF;
CLOSE cursore;
returns torna;
END $$
ERROR
CREATE FUNCTION `Dim_quant` (
prod int,
quant int
) RETURNS int BEGIN DECLARE orig int;
Messaggio di MySQL: Documentazione
#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 '' at line 4
qualcuno mi può spiegare il perché?