MySQL Cursor
This is the neatest MySQL cursor tutorial I've ever seen over the internet. So I got mine working. Check out Introduction to MySQL cursorThis is what I got now:
DELIMITER $$ USE `my_db`$$ DROP PROCEDURE IF EXISTS `SUBSCRIPTION_TYPE_PERCENTAGE`$$ CREATE PROCEDURE `my_db`.`SUBSCRIPTION_TYPE_PERCENTAGE`() BEGIN DECLARE subscriptionValue INT; DECLARE v_finished INTEGER DEFAULT 0; DECLARE amountCursor CURSOR FOR SELECT DISTINCT amount FROM subscription_items; DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_finished = 1; OPEN amountCursor; getSubscriptionValue: LOOP FETCH amountCursor INTO subscriptionValue; IF v_finished = 1 THEN LEAVE getSubscriptionValue; END IF; END LOOP getSubscriptionValue; CLOSE amountCursor; END$$ DELIMITER ;
HTG Explains: What is a File System, and Why Are There So Many of Them?
#shareablesoftheday
#fingersonpulse
No comments:
Post a Comment