MySQL error code:1329 in function

Posted by Sharad Sharma on Stack Overflow See other posts from Stack Overflow or by Sharad Sharma
Published on 2012-09-28T03:18:47Z Indexed on 2012/09/28 3:37 UTC
Read the original article Hit count: 176

Filed under:
DELIMITER //

CREATE DEFINER=`root`@`localhost` FUNCTION `formatMovieNames`(lID int) RETURNS varchar(1000) CHARSET latin1
BEGIN
    DECLARE output varchar(1000);
    DECLARE done INT DEFAULT 0;
    declare a varchar(200);
    declare cur1 cursor for select fileName from swlp4_movie where movieID in 
                    (select movieID from lesson_movie_map where lessonID = lID order by lm_map_id);
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    open cur1;
    read_loop: loop
        fetch cur1 into a;
        if done = 1 then
            leave read_loop;
        end if;
        set output = concat(output, 'movie:[',a,']<br/>');
        set output = substr(output, 0, length(@output)-5);
    end loop;
    close cur1;
RETURN output;
END//

I have create this function and when I run it I do not get any output

(select fileName from swlp4_movie where movieID in 
(select movieID from lesson_movie_map where lessonID = 24 order by lm_map_id));

brings correct result I am trying to get result as
movie:['movieName']< br / >movie:['movieName1'] and so on
(had to change br tag, cause it was adding a line break)

cant't figure out what I am doing wrong

© Stack Overflow or respective owner

Related posts about mysql