I am trying to learn how procedures work and I get an error and I don't know why.
DELIMITER //
CREATE PROCEDURE producer
(IN marcaMasinii VARCHAR(20))
SELECT DISTINCT producator, AVG(pret) AS medie
FROM vehicul v
JOIN proprietate p
ON v.id_vehicul = p.nr_vehicul
WHERE producator = marcaMasinii;
END //
DELIMITER ;
CALL producer("Dacia");
I have this procedure and I get an error on the line where "END //" is. The error sounds like this:
"Syntax error, unexpected END, expecting $END."
If I add the "BEGIN", the code looks like:
DELIMITER //
CREATE PROCEDURE producer
(IN marcaMasinii VARCHAR(20))
BEGIN
SELECT DISTINCT producator, AVG(pret) AS medie
FROM vehicul v
JOIN proprietate p
ON v.id_vehicul = p.nr_vehicul
WHERE producator = marcaMasinii;
END //
DELIMITER ;
CALL producer("Dacia");
The error looks like this:
"Syntax error, unexpected CREATE, expecting END_OF_INPUT or ;"
What's wrong with the syntax? Can someone explain?