Help with 1064 error
I am new to writing MySQL procedures. My first attempt seem to have a simple problem, but I can not figure it out after going to server books and sites. My code looks like this:
DROP PROCEDURE IF EXISTS sp_Page_View_Update;
CREATE PROCEDURE sp_Page_View_Update()
MODIFIES SQL DATA
BEGIN
DECLARE l_Cnt BIGINT DEFAULT 1;
DECLARE l_Page_ID BIGINT;
DECLARE l_Viewer_Name VARCHAR(255);
DECLARE l_View_Date DATETIME DEFAULT NOW();
DECLARE l_Done INT DEFAULT 0;
DECLARE cur1 CURSOR FOR
SELECT CONTENT.CONTENTID, user_mapping.lower_username
FROM CONTENT, user_mapping
Where CONTENTTYPE = "PAGE"AND CONTENT_STATUS = "current" AND CONTENT.LASTMODIFIER = user_mapping.user_key
Order by TITLE, VERSION DESC,CREATOR, LASTMODDATE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET l_Done=1;
SET l_Cnt = l_Cnt + 1;
OPEN cur1;
insert_loop: LOOP
FETCH cur1 INTO l_Page_ID, l_Viewer_Name
IF l_Done = 1 THEN
LEAVE insert_loop
End IF
INSERT INTO AO_1991C6_PAGE_VIEW(ID,PAGE_ID,VEIWER_ID,VIEW_DATE)
VALUES(l_Cnt,l_Page_ID,l_Viewer_Name,l_View_Date)
SET l_Cnt = l_Cnt + 1
END LOOP insert_loop;
CLOSE cur1;
END;
call sp_Page_View_Update;
(I hope it is ok to ask for help debugging my first attempt)
I get a 1064 error starting on the "CREATE PROCEDURE sp_Page_View_Update()
MODIFIES SQL DATA" line. It continues with all of the "Declare", "Set", "open", "insert_loop", "Close"' and "End" statements.
I think that the Create statement is the root problem, but I can not figure out what is wrong with it (or any of the rest of the program).
Please help me. Point me in the right direct.