MySQL Forums
Forum List  »  Stored Procedures

Procedure will not run
Posted by: Greg Della-Croce
Date: July 26, 2016 07:43AM

OK I have written other SQL statements/programs before. This is my first for MySQL 6.3 CE. I guess I am just blind but it is throwing an error with almost every line. Could one of you nice people point out the all to obvious error I am making in this procedure? Thanks -- Greg
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;

Options: ReplyQuote


Subject
Views
Written By
Posted
Procedure will not run
3175
July 26, 2016 07:43AM
415
July 26, 2016 11:15AM
366
July 27, 2016 07:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.