I have this routine working in dev, I went to copy it into production and I get a “check your syntax near…’ error on the Update line. It saves if I take out the limit clause.
Like I say, this is working in Dev. Copy and pasted the structure def, so I know it’s identical.
DELIMITER ;;
CREATE DEFINER=`user`@`%` PROCEDURE `SQS_Get_Messages`(IN queue_requested INT, IN queue_limit INT)
SQL SECURITY INVOKER
BEGIN
DECLARE my_uuid INT;
DECLARE fake INT;
DECLARE now DATETIME;
SELECT Get_Lock('message_get',10) INTO fake;
SELECT NOW() INTO now;
SELECT UNIX_TIMESTAMP()+mod(UUID_SHORT(),1000) INTO my_uuid;
UPDATE sqs SET `status`= my_uuid, `started_timestamp` = now WHERE `status` = 0 and `queue` = queue_requested LIMIT queue_limit;
SELECT RELEASE_LOCK('message_get') INTO fake;
SELECT `id`,`body`,`status` from sqs WHERE `status` = my_uuid;
END;;
DELIMITER ;
If it works in dev, but fails with a copy and paste into production, you have a version mismatch between your dev server and your production server, or you’ve failed to copy and paste properly. There aren’t any other explanations that I can see.