mysql表名作为参数传入存储过程

有以下存储过程:

CREATE DEFINER=`root`@`localhost` PROCEDURE `P_HoverTreePages`(
IN `TableName` VARCHAR(200),
IN `FieldList` VARCHAR(2000)
,
IN `PrimaryKey` VARCHAR(100),
IN `Where` VARCHAR(2000),
IN `Order` VARCHAR(1000),
IN `SortType` INT,
IN `RecorderCount` INT,
IN `PageSize` INT,
IN `PageIndex` INT,
OUT `TotalCount` INT,
OUT `TotalPageCount` INT )
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT 'fenye'
BEGIN set @sqlStr = CONCAT('select * from ',TableName);
prepare sqlStr from @sqlStr;
execute sqlStr; END

有这个表:

mysql表名作为参数传入存储过程

调用存储过程:

CALL `P_HoverTreePages`('t_hovertreenote', 'h', 'h', 'h', 'h', '', '', '', '', @hh, @yy)

结果:

mysql表名作为参数传入存储过程

上一篇:用原生JS写移动动画案例及实际应用


下一篇:java中main函数的String[] args