While loop with label : While « Procedure Function « SQL / MySQL






While loop with label

     

DELIMITER $$

CREATE PROCEDURE AGAIN
   (OUT RESULT INTEGER)
BEGIN
   DECLARE COUNTER INTEGER DEFAULT 1;
   SET RESULT = 0;
   LOOP1: WHILE COUNTER <= 1000 DO
      SET COUNTER = COUNTER + 1;
      IF COUNTER > 100 THEN
         LEAVE LOOP1;
      ELSE
         ITERATE LOOP1;
      END IF;
      SET RESULT = COUNTER * 10;
   END WHILE LOOP1;
END$$

DELIMITER ;

   
    
    
    
    
  








Related examples in the same category

1.WHILE Statement
2.While loop
3.IF statement in a While loop