2012-03-30 67 views
2

我在mysql中存儲過程。該過程被創建,但是當程序被稱爲我得到一個錯誤:mysql中使用存儲過程更新表

"Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect."

下面是該過程:

------------------------------------------------ 
drop procedure if exists update_per_det; 

delimiter // 

create procedure update_per_det(IN name varchar(30)) 

begin 

DECLARE age1 int; 

set age1=(select CalAge(name)); 

update per_det set age=age1 where username=name; 

end;// 

delimiter ; 

我怎樣才能解決這個問題呢?

+0

請了解如何格式化報價,代碼等閱讀常見問題以獲取更多信息。 – JonH 2012-03-30 13:37:19

回答

2

試試這個:

set age1=(select CalAge(name)); 

SET SQL_SAFE_UPDATES=0; 

update per_det set age=age1 where username=name; 
+0

謝謝你rs.its工作 – mani 2012-03-30 13:43:18

+0

如果它解決了你的問題/問題,請接受我的文章作爲答案。 http://meta.stackexchange.com/a/5235 – 2012-03-30 13:47:25