MySql存储过程循环游标-语法错误 [英] MySql Stored Procedure Loop Cursor - Syntax error
本文介绍了MySql存储过程循环游标-语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
语法错误在哪里?
DECLARE irid INT DEFAULT 0;
DECLARE tmp_joinid INT DEFAULT 0;
DECLARE loopjoins_eof INT DEFAULT FALSE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET loopjoins_eof = TRUE;
START TRANSACTION;
SET irid = (SELECT id FROM `tables` WHERE `adapter_id`=_aid AND `view_id`=_vid AND `name`=_tname);
IF irid IS NOT NULL THEN
DECLARE cur0 CURSOR FOR SELECT `joins`.`id` FROM `joins` WHERE `table_left_id`=irid OR `table_right_id`=irid;
OPEN cur0;
loopjoins: LOOP
FETCH cur0 INTO tmp_joinid;
IF loopjoins_eof THEN
LEAVE loopjoins;
END IF;
-- Lösche Join-Columns
DELETE FROM `join_columns` WHERE `join_id`=tmp_joinid;
END LOOP loopjoins;
CLOSE cur0;
END IF;
COMMIT;
SELECT irid;
1064-您的SQL语法有错误;在第12行
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE cur0 CURSOR FOR SELECT joins
.id
FROM joins
WHERE table_left_id
=i' at line 12
谢谢
推荐答案
查看全文