日期:2014-05-16 浏览次数:20917 次
CREATE PROCEDURE addCity6() BEGIN DECLARE done INT DEFAULT FALSE; DECLARE S_START CHAR(20); DECLARE S_END CHAR(20); DECLARE PRICE INT; DECLARE CUR CURSOR FOR SELECT start,price,end FROM truck WHERE id NOT IN ( select a.id from truck a, truck b where a.start=b.end and a.end = b.start); DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN CUR; REPEAT FETCH CUR INTO S_START,PRICE,S_END; IF NOT done THEN INSERT INTO truck(start,price,end)VALUES(S_END,PRICE,S_START); COMMIT; END IF; UNTIL done END REPEAT; CLOSE CUR; END;