0
在下面的過程中,我想將title_id設置爲@v_title_id變量,以便我可以在過程中使用它。任何想法thanx提前。我使用的是InnoDB引擎類型。存儲過程
DELIMITER //
DROP PROCEDURE IF EXISTS sp_Title_SplitGenres //
CREATE PROCEDURE sp_Title_SplitGenres
(
p_genre_id INT,
p_genre_str VARCHAR(2000)
)
BEGIN
SET @v_stringseperator = '::::' ;
SET @v_title_id = (select title_id from filmo_title_genre where genre_id = p_genre_id);
WHILE LENGTH(TRIM(p_genre_str)) > 0
DO
SET @v_curr_Str := (SELECT SUBSTRING_INDEX(p_genre_str, @v_stringseperator, 1));
SET p_genre_str = (SELECT LTRIM(TRIM(LEADING CONCAT(@v_curr_Str ,@v_stringseperator) FROM p_genre_str)));
create temporary table filmo_title_genre_temp
(
title_id int(11) NOT NULL,
genre_id int(11) NOT NULL,
sequence_num int(11) NOT NULL default '0',
PRIMARY KEY (title_id,genre_id,sequence_num)
)ENGINE = InnoDB;
while @v_title_id > 0
DO
select title_id,genre_id from filmo_title_genre where title_id = @v_title_id ;
END WHILE;
END WHILE;
REPLACE INTO filmo_title_genre
SELECT * FROM filmo_title_genre_temp;
drop table filmo_title_genre_temp;
delete from filmo_title_genre
where genre_id = p_genre_id;
END //
DELIMITER ;