失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > mysql用户自定义函数实例与部分问题解决方法【MySQL】

mysql用户自定义函数实例与部分问题解决方法【MySQL】

时间:2024-02-23 04:13:17

相关推荐

mysql用户自定义函数实例与部分问题解决方法【MySQL】

数据库|mysql教程

mysql,自定义函数

数据库-mysql教程

mysql用户自定义函数实例与部分问题解决方法_MySQL

discuz商品分类信息源码,使用ubuntu做开发,爬虫视频豆瓣分析,海康php,保山seo优化lzw

A、查看创建函数的功能是否开启:

js手机 源码,ubuntu全屏 vm,tomcat如何虚拟目录,python 爬虫 图书,php生成4位验证码,百度收录怎么做seolzw

mysql> show variables like \%func%;+-----------------------------------------+-------+| Variable_name | Value |+-----------------------------------------+-------+| log_bin_trust_function_creators | ON |+-----------------------------------------+-------+1 row in set (0.02 sec)

B、如果Value处值为OFF,则需将其开启。

smf论坛美化版源码下载,vscode的终端命令,最强ubuntu平板,a tomcat c手表,爬虫 xpath,php链 鄙视,泉州seo快速排名公司,国外c 源码网站源码,h5 html模板lzw

mysql> set global log_bin_trust_function_creators=1;use app02delimiter //mysql>DROP FUNCTION IF EXISTS `testhanshu`;CREATE FUNCTION `testhanshu`(`tustate` int)RETURNS varchar(2000)BEGINdeclare oneAddr varchar(200) default \;declare allAddr varchar(2000) default \;DECLARE done INT DEFAULT FALSE;declare curl CURSOR for select utruename from tsys_user where ustate = tustate;DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;open curl; REPEATFETCH curl INTO oneAddr;IF NOT done THENset oneAddr = CONCAT(oneAddr, ;);set allAddr = CONCAT(allAddr, oneAddr);END IF;UNTIL done END REPEAT;close curl;RETURN allAddr;END;mysql>select testhanshu(1);

在使用MySql自己定义的函数时,出现错误java.sql.SQLException: 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)

解决办法有三种:

1. 登录MySql客户端,执行: SET GLOBAL log_bin_trust_function_creators = 1;

2.在登录MySQL服务器是,在服务启动时加上 “–log-bin-trust-function-creators=1 ”参数并设置为1。

3.在my.ini(f)中的[mysqld]区段中加上 log-bin-trust-function-creators=1。

如果觉得《mysql用户自定义函数实例与部分问题解决方法【MySQL】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。