title: Stored procedure not working properly in MySql?
body: <p>I have been debugging a SQL stored procedure which has to take values (in my code ID and Numb) form table A based on the values (ID) present in the Table C, then square the Numb and store it in Table B i.e. all the things ID, Numb and Square.
  I am not able to figure out the problem in the below code </p>
  
  <pre><code> DELIMITER $$
      CREATE PROCEDURE matlab.squaring
       BEGIN
         DECLARE finish BOOLEAN DEFAULT 0; # &lt;- set up initial conditions
         DECLARE square BIGINT(10);
         DECLARE ID INT(10);
         DECLARE Numb INT (10);
         DECLARE id_cur CURSOR FOR
           SELECT ID, Numb FROM A WHERE EXISTS ( SELECT ID FROM c);
           SET @square= @Numb * @Numb
  
             INSERT INTO B
             (
               ID ,
               Numb ,
               square
             )     values ( ID , Numb, square);
  
  
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET finish = TRUE;
         OPEN id_cur;
  
       the_loop : LOOP
          FETCH id_cur INTO ID;
  
          IF finish THEN
             CLOSE id_cur;
             LEAVE the_loop;
          END IF
      END LOOP the_loop;
      END$$
  </code></pre>
  
  <p>When I run the stored procedure the error that pops up is "there seems to be some syntax error in your code, please refer to MYSql guide. "</p>
  
  <p>edit:
  one more help please how to execute this stored procedure.</p>