Everytime call this stored procedure i get this error:
#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 'NULL' at line 1
What seems to be the problem?
Here is the code:
DELIMITER $$
DROP PROCEDURE IF EXISTS `singledb`.`TOUR_TRANSFER`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `TOUR_TRANSFER`()
BEGIN
BEGIN -- for rubric table
DECLARE tblRubric_rubric_id INT;
SET @qry = concat('SELECT count(*) into ',tblRubric_rubric_id,' FROM zerodb2.tour_template');
PREPARE statement FROM @qry;
EXECUTE statement;
SELECT tblRubric_rubric_id;
END;
END$$
DELIMITER ;
From http://bugs.mysql.com/bug.php?id=15263:
So, we can not do:
We can not use
?instead of identifier (variable name).And when you use parameter name:
in the string being prepared, then server simply do not know what that
ridrefers to in statement you are trying to prepare. You may try to prepare it outside SP with the same result:So I just used user variable, see below: