這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)MySQL中創(chuàng)建存儲(chǔ)過(guò)程出現(xiàn)報(bào)錯(cuò)如何解決,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
成都創(chuàng)新互聯(lián)公司基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺(tái)為眾多戶提供綿陽(yáng)電信機(jī)房 四川大帶寬租用 成都機(jī)柜租用 成都服務(wù)器租用。
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
-> /*SELECT concat('[INFO] ', THE_REFERNCE_LABEL, ' reference not found.');*/
-> 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;
-> /*SELECT concat('[INFO] The query to execute is [', THE_QUERY, ']');*/
-> /*EXECUTE IMMEDIATE THE_QUERY into REFERENCE_LABEL, INSTALL_VERSION;*/
-> /*SELECT concat('[INFO] ', THE_REFERNCE_LABEL, ' reference found');*/
-> RETURN 0;
-> END $$
ERROR 1415 (0A000): Not allowed to return a result set from a function
mysql> delimiter ;
報(bào)錯(cuò)原因:
在MySQL的function里,不能使用SELECT語(yǔ)句來(lái)返回結(jié)果集,會(huì)報(bào)錯(cuò)。
注釋掉后,報(bào)錯(cuò)消失
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
-> /*SELECT concat('[INFO] ', THE_REFERNCE_LABEL, ' reference not found.');*/
-> 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;
-> /*SELECT concat('[INFO] The query to execute is [', THE_QUERY, ']');*/
-> /*EXECUTE IMMEDIATE THE_QUERY into REFERENCE_LABEL, INSTALL_VERSION;*/
-> /*SELECT concat('[INFO] ', THE_REFERNCE_LABEL, ' reference found');*/
-> RETURN 0;
-> END $$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
上述就是小編為大家分享的MySQL中創(chuàng)建存儲(chǔ)過(guò)程出現(xiàn)報(bào)錯(cuò)如何解決了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。