The given below code is part of stored procedure (mysql 5.5.20):
prepare stmnt1 from concat('insert into ' , tableName , '(employee_id , administrator_id) values(? , ?) ' ) ;
set @a = 19 ;
set @b = 11;
execute stmnt1 using @a , @b ;
tableName is local variable
When i create procedure i get this error :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'concat('insert into ' ,
tableName , '(employee_id , administrator_id) values(? ' at line 23
It seems that this kind of statement is not possible in mysql.
Please help.Thanks.
Try this one please.
set @sql = concat('insert into ' , tableName , '(employee_id , administrator_id) values(? , ?) ' ) ;
prepare stmnt1 from @sql;
set @a = 19 ;
set @b = 11;
execute stmnt1 using @a , @b ;
deallocate prepare stmnt1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With