Monday, 15 August 2011

CONCAT is not working in mysql stored procedure -



CONCAT is not working in mysql stored procedure -

drop procedure if exists cursor_test;# mysql returned empty result set (i.e. 0 rows). delimiter $$ create procedure cursor_test() begin declare project_number_val varchar( 255 ); declare project_list_val varchar(255); declare no_more_rows boolean; declare loop_cntr int default 0; declare num_rows int default 0; declare projects_cur cursor select project_id project_details; declare go on handler not found set no_more_rows = true; open projects_cur; select found_rows() num_rows; the_loop: loop fetch projects_cur project_number_val; if no_more_rows close projects_cur; leave the_loop; end if; set project_list_val=concat(`project_number_val`,'_list')

-

> ---> **please check doing concat right here?** insert test (panel_id) select panel_id project_list_val project_number_val='9'; > --->**is taking 9_list table name?** set loop_cntr = loop_cntr + 1; end loop the_loop; select num_rows, loop_cntr; end $$# mysql returned empty result set (i.e. 0 rows). delimiter

any suggestions? hi all,

i have variable in stored procedure named project_number , of varchar type.

my requirement "for each project number query table project_number_list results list , insert other table"

lets say, project_number might 22,21,34,43,434 corresponding tables need query 22_list, 21_list,34_list .....

i'm using cursor loop through project_number problem how mix project_number , _list i.e., 22_list query table 22_list

try :

set project_list_val=concat(project_number_val,'_list')

mysql stored-procedures

1 comment: