错误提示如下:
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)
原因:
- 创建存储函数:
create function fun_name([func_param[,…]])
[characteristic] routine_body
- bin-log
mysql默认开启了bin-log,
就必须指定**[characteristic**]是否是一下几种:
1 DETERMINISTIC 不确定的
2 NO SQL 没有SQl语句,当然也不会修改数据
3 READS SQL DATA 只是读取数据,当然也不会修改数据
4 MODIFIES SQL DATA 要修改数据
5 CONTAINS SQL 包含了SQL语句
解决办法:
set global log_bin_trust_function_creators=TRUE;
########################################################
DELIMITER $$
create function func_employee(id int(4))
RETURNS int(6)
COMMENT '查询某个员工的薪水'
BEGIN
RETURN(select salary from t_employee
where t_employee.id = id);
END;
$$
DELIMITER ;