在存储过程中怎样 把EXECUTE strsql 后值 赋值给变量 如
SET @strsql = CONCAT(
#”select sql_calc_found_rows @rowindex:=@rowindex+1 as rownumber,” #记录行号
“select count(0) ”
,” from ”
,_tables
,CASE IFNULL(_where, “”) WHEN “” THEN “” ELSE CONCAT(” where “, _where) END
);
PREPARE strsql FROM @strsql;#定义预处理语句
EXECUTE strsql ; #执行预处理语句
DEALLOCATE PREPARE strsql; #删除定义
SET @strsql = CONCAT(
#”select sql_calc_found_rows @rowindex:=@rowindex+1 as rownumber,” #记录行号
“select count(0) ”
,” from ”
,_tables
,CASE IFNULL(_where, “”) WHEN “” THEN “” ELSE CONCAT(” where “, _where) END
);
PREPARE strsql FROM @strsql;#定义预处理语句
EXECUTE strsql ; #执行预处理语句
DEALLOCATE PREPARE strsql; #删除定义
解决方案
40
用一个session变量传出来
CREATE PROCEDURE test()
begin
declare tmp int;
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