当过程名称在mysql中的变量中时,调用存储过程 [英] Call to stored procedure , when procedure name in a variable in mysql
本文介绍了当过程名称在mysql中的变量中时,调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有mysql存储过程,我想在使用准备好的语句的变量中调用该过程名称,但是它给了我一个错误,
我不是mysql方面的专家.这是准备好的语句
> PREPARE stmt1 FROM 'CALL ? (?,?,?)';
SET @q = 'sys_search';
SET @a ='All_Employees';
SET @b = 1;
SET @c = 1;
EXECUTE stmt1 USING @q,@a,@b,@c;
有人可以给我解决方案吗?
解决方案
@Rahul,@Tim Biegeleisen感谢您的答复. 我使用此语句来完成工作.
SET @q = 'sys_search';
SET @q2 = CONCAT('CALL ',@q,'(?,?,?)');
PREPARE stmt1 FROM @q2;
SET @a = 'All_Employees';
SET @b = 1;
SET @c = 1;
EXECUTE stmt1 USING @a, @b,@c;
I have mysql stored procedure and i want to call to that and procedure name in a variable i used prepared statements but it gave me an error ,
im not a expert in mysql.
here is the prepared statement
> PREPARE stmt1 FROM 'CALL ? (?,?,?)';
SET @q = 'sys_search';
SET @a ='All_Employees';
SET @b = 1;
SET @c = 1;
EXECUTE stmt1 USING @q,@a,@b,@c;
can any one give me the solution?
解决方案
@Rahul , @Tim Biegeleisen Thank you for your responses. I used this statements to work done.
SET @q = 'sys_search';
SET @q2 = CONCAT('CALL ',@q,'(?,?,?)');
PREPARE stmt1 FROM @q2;
SET @a = 'All_Employees';
SET @b = 1;
SET @c = 1;
EXECUTE stmt1 USING @a, @b,@c;
这篇关于当过程名称在mysql中的变量中时,调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文