Created
June 2, 2015 19:05
-
-
Save markbalt/720f21ad02b67b4f6ff7 to your computer and use it in GitHub Desktop.
Customer MySQL Cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP PROCEDURE IF EXISTS curupdate; | |
delimiter // | |
CREATE PROCEDURE curupdate() | |
BEGIN | |
DECLARE done INT DEFAULT 0; | |
DECLARE a INT; | |
DECLARE b CHAR(16); | |
DECLARE cur1 CURSOR FOR SELECT id,vantive_id FROM customer; | |
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; | |
OPEN cur1; | |
REPEAT | |
FETCH cur1 INTO a, b; | |
IF NOT done AND b IS NOT NULL THEN | |
INSERT INTO vantive_customer (customer_id, vantive_id) VALUES (a,b); | |
END IF; | |
UNTIL done END REPEAT; | |
CLOSE cur1; | |
END | |
// | |
DELIMITER ; | |
call curupdate(); | |
DROP PROCEDURE IF EXISTS curupdate; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment