MySQL Forums
Forum List  »  Stored Procedures

Re: Help with 1064 error
Posted by: Peter Brawley
Date: September 21, 2016 11:06AM

Not clear why this job can't be done with a straightforward Insert...Select statement, no sproc.

Errors found on a first pass, there might be more ...

DROP PROCEDURE IF EXISTS sp_Page_View_Update; 
delimiter //                                               -- MISSING DELIMITER DIRECTIVE                                                     
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;                                   -- ABOVE, DID YOU MEAN TO DEFAULT IT TO 2? 
  OPEN cur1; 
  insert_loop: LOOP 
    FETCH cur1 INTO l_Page_ID, l_Viewer_Name ;             -- MISSING TERMINATING SEMICOLON
    IF l_Done = 1 THEN 
      LEAVE insert_loop ;                                  -- MISSING TERMINATING SEMICOLON
    End IF ;                                               -- MISSING TERMINATING SEMICOLON
    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) ;  -- MISSING TERMINATING SEMICOLON
    SET l_Cnt = l_Cnt + 1 ;                                -- MISSING TERMINATING SEMICOLON
  END LOOP insert_loop; 
  CLOSE cur1; 
END; 
delimiter ;                                                -- RESTORE DEFAULT DELIMITER
call sp_Page_View_Update; 

Options: ReplyQuote


Subject
Views
Written By
Posted
3127
September 21, 2016 07:58AM
Re: Help with 1064 error
342
September 21, 2016 11:06AM
303
September 21, 2016 02:50PM
290
September 21, 2016 04:21PM
255
September 21, 2016 07:31PM


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.