mysql - stored procedure -


in below procedure want set title_id @v_title_id variable can use in procedure. ideas thanx in advance. i'm using innodb engine type.

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 filmo_title_genre genre_id = p_genre_id);          while length(trim( p_genre_str ))  > 0                  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)    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                  select title_id,genre_id filmo_title_genre title_id = @v_title_id ;         end while;          end while;          replace filmo_title_genre          select * filmo_title_genre_temp;         drop table filmo_title_genre_temp;                delete filmo_title_genre        genre_id = p_genre_id;  end //  delimiter ; 

i'm not of mysql person (didn't see tag til opened this), think want use select not set when trying set variable select statement. you're cluing parser being table operation.

select @v_title_id := title_id filmo_title_genre genre_id = p_genre_id; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -