0
I am trying to make a trial with the following mysql block:
DECLARE done         INT DEFAULT FALSE;
DECLARE v_id         INT;
DECLARE R CURSOR FOR 
                            SELECT  id                                     
                                   ,nome
                              FROM pessoa d                               
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN R;
 read_loop: LOOP
    FETCH R INTO v_id;
      IF done THEN
        LEAVE read_loop;
      END IF;
      SELECT DATE_FORMAT(previsao,'%d/%m/%Y') as doba_dt_previsao
                             ,usuario_id
                         FROM documentos 
                        WHERE doc_pess_id = (
                                        SELECT MAX(doc_ID) ID
                                         FROM DOCUMENTOS
                                        WHERE doc_pess_id = v_id
                       )
                       AND docu_quitr IS NULL
                       AND previsao < DATE(NOW()) 
    END LOOP;
  CLOSE R;  
I wonder if you have to show only select values from within the loop, in a single select.
Because I understand that every time he runs the loop he will do the select, I wonder if he has how to store these values of the loop in a variable so then I show?
I don’t know if it would be right to give one select from a cursor
Create another cursor inside the loop to show?
It’s because I researched, I don’t know if I researched properly, but I didn’t find
See here. http://www.mysqltutorial.org/mysql-cursor/
– Reginaldo Rigo