Trying to migrate from MSSQL to MySQL. This Stored Proc is creating a temp table for some columns from a permanent table then using a cursor to update each record's RandNum column with a random number and selects the dataset. As I'm writing this I thought that I could bypass the cursor and just...
SELECT Id, Title, DateStart, Rand() FROM cms_News;
But i dont want to change anything too drastic, because right now I'm just trying to convert the DB. I will go back and optimize this stuff later. Here's the SP: EDIT: I removed all of the code from this example that has nothing to do with the error. Also, I saw this online today and it seems that I'm not the only one who is having this issue. MySQL does not like the syntax of my cursor declaration. Any Ideas?
DELIMITER ;//
DROP PROCEDURE IF EXISTS `cms_NewsSelectMainPageNews`;//
CREATE PROCEDURE `cms_NewsSelectMainPageNews`
()
BEGIN
CREATE TEMPORARY TABLE tempNews
(
Id int NOT NULL,
Title nvarchar(250),
DateStart datetime,
RandNum float NULL
);
DECLARE Randomizer CURSOR
FOR SELECT Id FROM tempNews;
END;//