在mysql存储过程中,如何将execute执行的语句的结果赋值给一个变量呢?
通过实验,可以使用这样的方法:
CREATE PROCEDURE test()
begin
declare tmp int;
set @sql = 'select count(*) into @count_tmp from tb1';
prepare stmt from @sql;
execute stmt;
set tmp = @count_tmp;
deallocate prepare stmt;
end
|
阅读(3027) | 评论(2) | 转发(0) |