Created
March 8, 2011 19:41
-
-
Save gmgent/860870 to your computer and use it in GitHub Desktop.
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
| CREATE PROCEDURE testy () | |
| BEGIN | |
| declare a, b int; | |
| DECLARE done int DEFAULT 0; | |
| DECLARE masterCursor CURSOR | |
| FOR | |
| SELECT SUM(sales.amount) amt, sales.item_month | |
| FROM sales | |
| WHERE RETAILER_ID = 336 | |
| GROUP BY sales.item_month; | |
| DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; | |
| OPEN masterCursor; | |
| REPEAT | |
| FETCH masterCursor INTO a, b; | |
| IF NOT done THEN | |
| insert into revplan (amount, item_month) | |
| values (a,b); | |
| END IF; | |
| UNTIL done END REPEAT; | |
| CLOSE masterCursor; | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment