title: Looping through multiple loops in
body: <pre><code>DROP PROCEDURE fillBin;
  DELIMITER $$
   CREATE  PROCEDURE fillBin(IN a INT(11), IN b INT(11), IN c INT(11), IN d INT(11), IN e     INT(11))
  wholeblock:BEGIN
   DECLARE i INT UNSIGNED DEFAULT 1;
   DECLARE j INT UNSIGNED DEFAULT 1;
   DECLARE k INT UNSIGNED DEFAULT 1;
   DECLARE l INT UNSIGNED DEFAULT 1;
   DECLARE m INT UNSIGNED DEFAULT 1;
   DECLARE strA VARCHAR(255) DEFAULT '';
   DECLARE strB VARCHAR(255) DEFAULT '';
   DECLARE strC VARCHAR(255) DEFAULT '';
   DECLARE strD VARCHAR(255) DEFAULT '';
   DECLARE strE VARCHAR(255) DEFAULT '';
   DECLARE strF VARCHAR(255) DEFAULT '';
  
   SET strA = 'A';
   SET strB = 'G';
   SET strC = 'R';
   SET strD = 'S';
   SET strE = 'B';
   SET strF= '';
  
   WHILE i &lt; (a+1) DO
   SET strA=CONCAT(strA,i) ;
  WHILE j &lt; (b+1) DO
  SET strB = CONCAT(strB,j);
      WHILE k &lt; (c+1) DO
      SET strC =CONCAT(strC,k);
          WHILE l &lt; (d+1) DO
          SET strD = CONCAT(strD,l);
              WHILE m &lt; (e+1) DO
              SET strE = CONCAT(strE,m);
              SET strF = CONCAT(strA, strB, strC, strD, strE);
              INSERT INTO BIN (`aisle`, `room`, `rack`, `shelf`, `bin`, `barcode`, `warehouse_id`) 
              VALUES(strA,strB, strC, strD, strE, strF, 1);
  
  SET m=m+1;
  SET strE = 'B';
  END WHILE;
  SET l=l+1;
  SET strD = 'S';
  END WHILE;
  SET k=k+1;
  SET strC = 'R';
  END WHILE;
  SET j=j+1;
  SET strB = 'G';
  END WHILE;
  SET i=i+1;
  SET strA = 'A';
  END WHILE;
  END $$
  
  //calling the procedure
  CALL fillBin(1, 1, 1, 2, 2);
  </code></pre>
  
  <p>My procedure inserts the values: A1G1R1S1B1 and A1G1R1S1B2. And the inner loop breaks.</p>
  
  <p>but the correct insertion should be: A1G1R1S1B1 and A1G1R1S1B2 and A1G1R1S2B1 and A1G1R1S2B2.</p>
  
  <p>The insert is obviously incomplete. How should I place my insert statement or change the looping as to cater the needs?</p>
  
  <p>Please help. Thanks</p>