mysql中不能創建函數的處理方法

 

在使用MySQL數據庫時,有時會遇到MySQL函數不能創建的情況。下面就教您一個解決MySQL函數不能創建問題的方法,供您借鑑參考。

出錯信息大致類似:

ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

MySQL函數不能創建,是未開啓功能:

  1. mysql> show variables like '%func%';  
  2. +---------------------------------+-------+  
  3. | Variable_name                   | Value |  
  4. +---------------------------------+-------+  
  5. | log_bin_trust_function_creators | OFF   |  
  6. +---------------------------------+-------+  
  7. 1 row in set (0.00 sec)  
  8.  
  9. mysql> set global log_bin_trust_function_creators=1;  
  10. Query OK, 0 rows affected (0.00 sec)  
  11.  
  12. mysql> show variables like '%func%';  
  13. +---------------------------------+-------+  
  14. | Variable_name                   | Value |  
  15. +---------------------------------+-------+  
  16. | log_bin_trust_function_creators | ON    |  
  17. +---------------------------------+-------+  
  18. 1 row in set (0.00 sec)mysql> 
 
注意:在mysql環境中創建函數和過程時必須加入  delimiter $$ 和結束的 $$ 否則會報語法錯誤。
delimiter $$
drop function getParamDescByValue;
create function getParamDescByValue(
in_sParamCode 	VARCHAR(64),
in_sParamValue	VARCHAR(64)
) returns VARCHAR(255)
begin
DECLARE v_sTemp VARCHAR(255);
select  param_desc into @v_sTemp from info_param where param_code = in_sParamCode and  param_value = in_sParamValue;
return @v_sTemp;
end$$
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章