title: MySQL Stored Procedure, cursor not open (1326)
body: <p>So, I am trying to get some result out about a SELECT request but every time I try to call the procedure it gives me : </p>
  
  <pre><code>mysql&gt; call canIDoThisSequenceSire(38,18);
  ERROR 1326 (24000): Cursor is not open
  </code></pre>
  
  <p>And I have no idea why, I think my cursor is open correctly (I have used this kind of code skeletton (got from here) on other stores procedures and it worked fine) and after trying to find someone with a similar error, I only got people who didn't use the OPEN curl line.</p>
  
  <p>Here is the code</p>
  
  <pre><code>PROCEDURE `canIDoThisSequenceSire`(in idOpe INT, in idSeq INT)
  BEGIN
  
  DECLARE done INT default FALSE;
  DECLARE isRoot,seqParent, seqDone INT;
  
  
  DECLARE curl CURSOR FOR SELECT 
      se.isRoot, se.id_sequenceEnchainement
      FROM 
          tachesrealisees as tr
      JOIN
          collectiontache as ct
      ON
          ct.id = tr.id_collectiontache
      JOIN
          tache as t
      ON
          t.id=ct.id_tache
      JOIN 
          sequences as s
      ON 
          s.id = ct.id_sequences
      JOIN
          sequenceenchainement as se
      ON
          se.id_sequence=s.id
      WHERE 
          tr.id_operationsrealisees=idOpe
      AND 
          s.id=idSeq;
  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
  
  OPEN curl;
  
  
  laBoucle : LOOP
      FETCH curl INTO isRoot, seqParent;
      IF isRoot THEN
          SET done = TRUE;
          LEAVE laBoucle;
      END IF;
  
      IF ISNULL(isRoot) then
          LEAVE laBoucle;
      END IF;
  
      CLOSE curl;
  
      END LOOP laBoucle;
  
      IF done THEN -- La séquence est à la racine
          SELECT 1 as result; 
      END IF;
  
      IF NOT done THEN 
              SELECT 0 as result; -- Please, come again
      END IF;
  
  END
  </code></pre>
  
  <p>Thanks!</p>