日期:2014-05-16  浏览次数:20739 次

储蓄过程变量问题
create   procedure   test(   in   tbl   varchar(32),out   cnt   int(11)   )
begin
/*
这里怎么写执行类似
select   count(*)   into   cnt   from   {$tbl};
的语句
*/
end

------解决方案--------------------
参考:

create procedure countNum
(
in tbName varchar(100),
out allPages int
)
begin
set @sqlStr = CONCAT( 'select count(*) into @allPages from ',tbName);
prepare sqlstmt from @sqlStr;
execute sqlstmt;

set allPages = @allPages;

deallocate prepare sqlstmt;
end;
------解决方案--------------------
http://blog.chinaunix.net/u/29134/showart_255219.html