Nested loop with cursor in procedure
This snippet just showing how to make nested loops with cursors in MySQL.
Copy this code and paste it in your HTML
DELIMITER //
OPEN cursorWard;
FETCH cursorWard
INTO wardName
; OPEN cursorLanglat;
FETCH cursorLangLat
INTO Lang
, Lat
;
INSERT INTO `points` SET `coordinates` = GeomFromText(CONCAT('POINT(', Lang
, ' ', Lat
,')')), `type` = wardName
, to_text
= CONCAT(Lang
, ',', Lat
), `description` = 'Queensland territory';
INSERT INTO `points` SET `coordinates` = GeomFromText(CONCAT('POINT(', firstLang
, ' ', firstLat
,')')), `type` = wardName
, to_text
= CONCAT(firstLang
, ',', firstLat
), `description` = 'Queensland territory';
CLOSE cursorLangLat;
CLOSE cursorWard;
DELIMITER ;
CALL createQueenslandWards
();
Report this snippet
Comments
Subscribe to comments