title: MySQL stored procedure cursor not working
body: <p>MySQL 5.5</p>
  
  <pre><code>CREATE TABLE `card` (
    `id` int,
    `cardnumber` varchar(100),
    `customer` varchar(100),
    PRIMARY KEY (`id`)
  );
  
  INSERT INTO `card` VALUES (1, '5000', 'Google');
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>DELIMITER // 
  CREATE PROCEDURE `test` ()
  BEGIN 
  
  DECLARE finished INTEGER DEFAULT 0;
  DECLARE cardnumber varchar(20) DEFAULT "";
  DECLARE cursor1 CURSOR FOR SELECT cardnumber FROM card WHERE customer = 'Google';
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
  
  OPEN cursor1;
  get_card: LOOP
  
    FETCH cursor1 INTO cardnumber;
    IF finished = 1 THEN 
      LEAVE get_card;
    END IF;
  
  END LOOP get_card; 
  
  SELECT cardnumber;
  
  CLOSE cursor1;
  END // 
  DELIMITER ;
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>CALL test();
  </code></pre>
  
  <p>Returns no results, what did I do wrong?</p>