List:General Discussion« Previous MessageNext Message »
From:Adam Gerson Date:October 4 2011 9:20pm
Subject:Variables in stored procedure
View as plain text  
I am getting the error that "TABLENAME" does not exist. How do I get it 
to substitute the value stored in TABLENAME, and not the literal string?

begin

declare v_max int unsigned default 1;
declare v_counter int unsigned default 21;
declare TABLENAME text;

   start transaction;
   while v_counter <= v_max do
	SET TABLENAME = CONCAT('wp_',v_counter, '_options');
	INSERT INTO TABLENAME VALUES ('309', '0', 'statpress_mincap', 
'edit_posts', 'yes');
     set v_counter=v_counter+1;
   end while;
   commit;
END


Thanks,
Adam

-- 
Adam Gerson
Co-Director of Technology
Columbia Grammar and Prep School
phone. 212-749-6200 ex. 321
fax.  212-428-6806
agerson@stripped
http://www.cgps.org

Thread
Variables in stored procedureAdam Gerson4 Oct
  • Re: Variables in stored procedurePeter Brawley4 Oct
  • Re: Variables in stored procedureluiz rodrigo mottin4 Oct
    • Re: Variables in stored procedureAdam Gerson5 Oct
Re: Variables in stored procedureluiz rodrigo mottin5 Oct