问题已撤回!当我拼写一切正确时,问题消失了!
我有一个创建临时表的MySQL存储过程。当我从mysql提示符中调用该过程时,它似乎成功运行,但如果我然后从临时表中选择COUNT(*),我会收到一个错误,说该表不存在。
在存储过程内创建的临时表是否在存储过程结束时停止存在?
mysql> delimiter //
mysql> drop procedure if exists sp_temp_reciepts//
mysql> create procedure sp_temp_receipts ()
begin
drop temporary table if exists receipts;
create temporary table receipts
( ... snip ...
);
insert into receipts
select ... snip ...
end//
mysql> delimiter ;
mysql> call sp_temp_reciepts();
Query OK, 46903 rows affected, 1 warning (2.15 sec)
mysql> select count(*) from receipts;
ERROR 1146 (42S02): Table 'receipts' doesn't exist
reciepts
和receipts
混用。 - favorettidrop procedure if exists f(); delimiter $ create procedure f()begin drop temporary table if exists t; create temporary table t select 1; select*from t; end$ delimiter ; call f(); select count(*)from t;
- Pacerier