How to create unique temporary tables in MySQL procedures? -
i creating temporary table in procedure, got error "table exists".
then tried create random name avoid collision don't know enough how execute sql strings
set @tbname = concat('temp', random_id); prepare stmt1 'create temporary table ? (`fieldname` float not null);'; execute stmt1 using @tbname; deallocate prepare stmt1;
the code above doesn't works. why? how correct it?
mysql> set @table_name := 'mytable'; query ok, 0 rows affected (0.02 sec) mysql> set @sql_text:=concat('create table ',@table_name,'(id int unsigned)'); query ok, 0 rows affected (0.00 sec)
from http://rpbouman.blogspot.com/2005/11/mysql-5-prepared-statement-syntax-and.html
Comments
Post a Comment