I'm trying to call a stored procedure inside another stored procedure.
I'm getting a syntax error in the statement where main procedure calls the child procedure.
here is my query
DROP PROCEDURE GetAllProducts;
DELIMITER //
CREATE PROCEDURE GetAllProducts()
BEGIN
DECLARE finished INT DEFAULT 0;
DECLARE myName varchar(60);
DEClARE myCursor CURSOR FOR
SELECT Name FROM Test;
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET finished =1 ;
OPEN myCursor;
get_email: LOOP
FETCH myCursor INTO myName;
IF finished = 1 THEN
LEAVE get_email;
END IF;
-- Line which shows a syntax error
EXEC UpdateProdcut myName;
END LOOP get_email;
CLOSE myCursor;
DEALLOCATE myCursor;
END //
DELIMITER ;
This is the error message
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 'UpdateProdcut myName OUTPUT;
mysql version is 5.5.54
any idea about this ?
Thanks.
Use CALL
instead:
call UpdateProdcut(myName);
execute
is used for prepared statements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.