在mysql中创建函数不成功(确定能创建函数)?

在mysql中创建函数不成功(确定能创建函数)CREATE function SplitString( String varchar(2048), SplitChar char)returns res table( Value varchar(128), vindex int)begin declare index int,unit varchar(128),inext int,len int,i int; set index=1; set i=1; set len=len(String); while index<=len begin set inext=charindex(SplitChar,String,index); if inext=0 set inext=len+1; if inext>index begin set unit=ltrim(rtrim(substring(String,index,inext-index))); if unit<>'' begin insert into res (value,vindex) values (unit,i); set i=i+1; end; end; set index=inext+1; end; return;end;源代码来自于http://www.cnblogs.com/lucc/archive/2009/02/14/1390384.html截个图给大侠们看看,,




30秒到达战场
浏览 934回答 2
2回答

暮色呼如

在使用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函数不能创建,是未开启功能:123456789101112131415161718mysql>&nbsp;show&nbsp;variables&nbsp;like&nbsp;'%func%';&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;|&nbsp;Variable_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Value&nbsp;|&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;|&nbsp;log_bin_trust_function_creators&nbsp;|&nbsp;OFF&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)&nbsp;&nbsp;&nbsp;&nbsp;mysql>&nbsp;set&nbsp;global&nbsp;log_bin_trust_function_creators=1;&nbsp;&nbsp;Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.00&nbsp;sec)&nbsp;&nbsp;&nbsp;&nbsp;mysql>&nbsp;show&nbsp;variables&nbsp;like&nbsp;'%func%';&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;|&nbsp;Variable_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Value&nbsp;|&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;|&nbsp;log_bin_trust_function_creators&nbsp;|&nbsp;ON&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;+---------------------------------+-------+&nbsp;&nbsp;1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)mysql>

繁花不似锦

你那个是&nbsp;&nbsp; SQL Server&nbsp;&nbsp; 特有的&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 表值函数。也就是一个函数,&nbsp;&nbsp; 返回一个结果集合的。&nbsp;MySQL&nbsp; 好像是不支持表值函数的样子。&nbsp;&nbsp; (现在最新的版本支持不支持,&nbsp; 你需要去看看 文档了)&nbsp;你可以尝试修改成&nbsp; 存储过程&nbsp; 返回结果集的处理。&nbsp;&nbsp;1234567891011121314151617DELIMITER&nbsp;//CREATE&nbsp;DEFINER=`root`@`%`&nbsp;PROCEDURE&nbsp;testProc()BEGIN&nbsp;&nbsp;SELECT&nbsp;'Hello&nbsp;1'&nbsp;AS&nbsp;A,&nbsp;'World&nbsp;1'&nbsp;AS&nbsp;B&nbsp;UNION&nbsp;ALL&nbsp;&nbsp;SELECT&nbsp;'Hello&nbsp;2'&nbsp;AS&nbsp;A,&nbsp;'World&nbsp;2'&nbsp;AS&nbsp;B;END&nbsp;//DELIMITER&nbsp;;&nbsp;mysql>&nbsp;call&nbsp;&nbsp;testProc();+---------+---------+|&nbsp;A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|+---------+---------+|&nbsp;Hello&nbsp;1&nbsp;|&nbsp;World&nbsp;1&nbsp;||&nbsp;Hello&nbsp;2&nbsp;|&nbsp;World&nbsp;2&nbsp;|+---------+---------+2&nbsp;rows&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.01&nbsp;sec)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL