大伙帮我看下这个存储过程哪里出了问题!

邻里 发布于 2016/08/19 01:18
阅读 265
收藏 0

收藏!数据建模最全知识体系解读!>>>

麻烦大家帮忙看下下面两个存储过程!前面个正确,后面个不正确!一执行就 unknown table. 但是我把SQL语句拿出来执行不会有问题,唯独在预处理里会有问题!为什么有问题,有谁能解答下吗?

BEGIN
	drop TEMPORARY table if EXISTS temp_a;
	set @ss= 'create TEMPORARY table temp_a as select ? as a, a.* from (select 1 as id, \'8开\' as attr_value, 15 as price union select 1 as id, \'16开\' as attr_value, 25 as price) a';
	PREPARE pname from @ss;
	EXECUTE pname using @a;
	DEALLOCATE PREPARE pname;
  	DROP TEMPORARY table temp_a; #删除临时表
END



下面个错误,但我实在看不出来它为什么哪里错误!

BEGIN
	drop TEMPORARY table if EXISTS temp_a;
	set @ss= 'create TEMPORARY table temp_a as select 1 as id, \'8开\' as attr_value, 15 as price union select 1 as id, \'16开\' as attr_value, 25 as price';
	PREPARE pname from @ss;
	DEALLOCATE PREPARE pname;
  	DROP TEMPORARY table temp_a; #删除临时表
END




以下是问题补充:

@邻里:我想到个问题是不是一定要?预处理参数才可以??? (2016/08/19 02:12)
加载中
返回顶部
顶部