我正在使用python调用一个创建临时表的存储过程。
然后,我尝试从该表中进行选择,但出现错误
Caught an exception while rendering: (1137, "Can't reopen table: 'temporary_name'")有人能看出我哪里错了吗?
我的代码是
# create a cursor
cur = connection.cursor()
# execute the stored procedure
cur.callproc('nodetree')
# Get results from stored procedure
sql = "SELECT * FROM temporary_name"
cur.execute(sql)这个表不叫temporary_name,我只是把它放进去,例如
发布于 2011-08-05 16:41:18
来自MySQL documentation (参见粗体文本):
不能在同一查询中多次引用临时表。例如,以下代码不起作用:
mysql> SELECT * FROM temp_table,temp_table AS t2;错误1137:无法重新打开表:'temp_table‘
如果在不同别名下多次引用存储函数中的临时表,即使引用出现在函数的不同语句中,也会出现此错误。
发布于 2020-06-07 21:25:05
您可以使用通常的表,然后删除它。
https://stackoverflow.com/questions/6953519
复制相似问题