这期内容当中小编将会给大家带来有关Mysql中创建存储过程出现报错如何解决,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。 mysql>
这期内容当中小编将会给大家带来有关Mysql中创建存储过程出现报错如何解决,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
mysql> delimiter $$
mysql> CREATE FUNCTioN check_rollbackPatch(THE_REFERNCE_LABEL VARCHAR(75), THE_COLUMN_NAME VARCHAR(75), THE_INSTALL_VERSION VARCHAR(75), THE_VERSION_LEVEL_TABLE_NAME VARCHAR(75))
-> RETURNS INTEGER DETERMINISTIC
-> BEGIN
-> DECLARE INSTALL_VERSION VARCHAR(80) DEFAULT NULL;
-> DECLARE REFERENCE_LABEL VARCHAR(80) DEFAULT NULL;
-> DECLARE THE_QUERY VARCHAR(500) DEFAULT NULL;
-> DECLARE too_many_rows CONDITION FOR 1172;
-> DECLARE CONTINUE HANDLER FOR too_many_rows
-> BEGIN
-> SELECT concat('[INFO] Several ', THE_REFERNCE_LABEL, ' references found.');
-> RETURN 0;
-> END;
-> DECLARE CONTINUE HANDLER FOR NOT FOUND
-> BEGIN
->
-> RETURN 1;
-> END;
-> SELECT concat('', THE_COLUMN_NAME, ', C_INSTALL_VERSION') INTO @V_PART1;
-> SELECT concat(THE_COLUMN_NAME, '=''', THE_REFERNCE_LABEL, ''' and C_INSTALL_VERSION=''', THE_INSTALL_VERSION, '''') INTO @V_PART2;
-> SELECT fORMat_selectQuery(THE_VERSION_LEVEL_TABLE_NAME, @V_PART1, @V_PART2) INTO THE_QUERY;
->
->
->
-> RETURN 0;
-> END $$
ERROR 1415 (0A000): Not allowed to return a result set from a function
mysql> delimiter ;
报错原因:
在MySQL的function里,不能使用SELECT语句来返回结果集,会报错。
注释掉后,报错消失
mysql> delimiter $$
mysql> CREATE FUNCTION check_rollbackPatch(THE_REFERNCE_LABEL VARCHAR(75), THE_COLUMN_NAME VARCHAR(75), THE_INSTALL_VERSION VARCHAR(75), THE_VERSION_LEVEL_TABLE_NAME VARCHAR(75))
-> RETURNS INTEGER DETERMINISTIC
-> BEGIN
-> DECLARE INSTALL_VERSION VARCHAR(80) DEFAULT NULL;
-> DECLARE REFERENCE_LABEL VARCHAR(80) DEFAULT NULL;
-> DECLARE THE_QUERY VARCHAR(500) DEFAULT NULL;
-> DECLARE too_many_rows CONDITION FOR 1172;
-> DECLARE CONTINUE HANDLER FOR too_many_rows
-> BEGIN
->
-> RETURN 0;
-> END;
-> DECLARE CONTINUE HANDLER FOR NOT FOUND
-> BEGIN
->
-> RETURN 1;
-> END;
-> SELECT concat('', THE_COLUMN_NAME, ', C_INSTALL_VERSION') INTO @V_PART1;
-> SELECT concat(THE_COLUMN_NAME, '=''', THE_REFERNCE_LABEL, ''' and C_INSTALL_VERSION=''', THE_INSTALL_VERSION, '''') INTO @V_PART2;
-> SELECT format_selectQuery(THE_VERSION_LEVEL_TABLE_NAME, @V_PART1, @V_PART2) INTO THE_QUERY;
->
->
->
-> RETURN 0;
-> END $$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
上述就是小编为大家分享的MySQL中创建存储过程出现报错如何解决了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注编程网数据库频道。
--结束END--
本文标题: MySQL中创建存储过程出现报错如何解决
本文链接: https://lsjlt.com/news/57241.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0