Created
August 28, 2013 20:17
-
-
Save raphaelchaib/6370688 to your computer and use it in GitHub Desktop.
MySQL: WHILE statement schema (Need to finish it)
This file contains hidden or 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
| DELIMITER $$ | |
| CREATE PROCEDURE fillPaisesNome() | |
| BEGIN | |
| DECLARE paisesNoName INT; | |
| DECLARE controle INT; | |
| SET paisesNoName = (SELECT COUNT(*) FROM `io_paises` WHERE `io_paises`.`nome` IS NULL); | |
| SET controle = 0; | |
| WHILE controle < paisesNoName DO | |
| UPDATE `io_paises` AS `pais` | |
| SET `pais`.`nome` = ( | |
| SELECT `trans`.`nome` | |
| FROM `io_paises_translation` AS `trans` | |
| WHERE `trans`.`id` = `pais`.`id` | |
| ) | |
| WHERE `pais`.`nome` IS NULL; | |
| commit; | |
| SET controle = controle + 1; | |
| END WHILE; | |
| END; | |
| DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment