MySQL New Features #5

  • MySQL New Features
  • Cursor Example:
    CREATE PROCEDURE p25 (OUT return_val INT)BEGINDECLARE a,b INT;DECLARE cur_1 CURSOR FOR SELECT s1 FROM t;DECLARE CONTINUE HANDLER FOR NOT FOUND < --SET b = 1; <--OPEN cur_1;REPEATFETCH cur_1 INTO a;UNTIL b = 1END REPEAT;CLOSE cur_1;SET return_val = a;END;//
  • Stored procedure in MySQL http://www.mysqltutorial.org/stored-procedures-loop.aspx
  • Loop in stored procedure
    DELIMITER $$ DROP PROCEDURE IF EXISTS WhileLoopProc$$ CREATE PROCEDURE WhileLoopProc()       BEGIN               DECLARE x  INT;               DECLARE str  VARCHAR(255);               SET x = 1;               SET str =  '';               WHILE x  < = 5 DO                           SET  str = CONCAT(str,x,',');                           SET  x = x + 1;                END WHILE;               SELECT str;       END$$   DELIMITER ;
  • MySQL Stored Procedure Example
  • From: http://sitestree.com/?p=5272
    Categories:5
    Tags:
    Post Data:2008-04-12 21:14:20

        Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
        (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
        In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
        <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
        8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
        Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
        Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>