Impavid Impavid - 3 months ago 20
MySQL Question

MySQL Version '5.7.14' SET pProd := pFac1 * pFac2;

The following 'CREATE PROCEDURE' statement from MySQL Connector/Python Developer Guide is not working in MySQL Version '5.7.14':

CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
BEGIN
SET pProd := pFac1 * pFac2;
END;


Please help fix this error:
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 '' at line 3

Answer

You probably need a delimiter wrapper

DROP PROCEDURE IF EXISTS multiply;
DELIMITER $$
CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
BEGIN
  SET pProd := pFac1 * pFac2;
END;$$
DELIMITER ;