mysql - Split string procedure can't find table -


i trying procedure work , stumping me. want procedure populate temp table separated values table of csv values.

delimiter $$  drop procedure if exists string_split $$  create procedure string_split (     vstring varchar(255),     vseparator varchar(5) ) begin  declare vdone tinyint(1) default 1; declare vindex int default 1; declare vsubstring varchar(15);  drop table if exists tmpvalues; create temporary table tmpvalues (tmpval varchar(255));  while vdone > 0     set vsubstring = substring(vstring, vindex,     if(locate(vseparator, vstring, vindex) > 0,         locate(vseparator, vstring, vindex) - vindex,         length(vstring)         ));     if length(vsubstring) > 0         set vindex = vindex + length(vsubstring) + 1;         insert tmpvalues values (vsubstring);     else         set vdone = 0;     end if; end while;  end; $$ 

i call on it:

call string_split(my_csv.keywords, ','); 

and this: error code: 1109. unknown table 'my_csv' in field list

i'm not getting because table there , appropriate database selected.

create table `my_csv` ( `id` int(10) not null auto_increment, `keywords` text not null, primary key (`id`) ) engine=myisam default charset=latin1 $$  insert `my_csv` () values (1, 'featured, 3/8, diamond, engagement ring, 14k, white gold, gold'), (2, '1/3, diamond, engagement ring, 14k, white gold, gold'), (3, 'featured') $$ 

instead of calling table name , field in call function, need value first, call procedure. here's working example.

select @keyword :=keywords my_csv; call string_split(@keyword, ','); 

edit: grabbed last row. one selects of them. also, doing vseparator variable in procedure small, bumped 255.

select @keyword :=group_concat(keywords) my_csv; call string_split(@keyword, ','); select * tmpvalues; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -