2011-08-05 25 views
0

我使用Python來調用它創建了一個臨時表的存儲過程MySQL錯誤 - 「不能重新打開表:「temporary_name」

然後我試圖從該表中選擇,但我得到錯誤

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我只是把它放在例如

+0

請給我們程序代碼。 – CappY

回答

0

MySQL documentation(見粗體文本):

您不能引用到一個臨時表不止一次在相同的查詢。例如,下面不工作:

mysql> SELECT * FROM temp_table, temp_table AS t2; 
ERROR 1137: Can't reopen table: 'temp_table' 

也會出現此錯誤如果你指到一個臨時表中多次存儲的作用下,不同的別名,即使發生在函數中不同的語句引用。

+0

我在我的存儲過程中沒有任何別名 – John

+0

@John您能夠執行存儲過程和命令行客戶端的選擇查詢嗎?你在哪裏拋出異常:'callproc()'或'execute()'? – Vlad