I have the following Store Procedure:
DELIMITER $$
USE 'open_bd'$$
DROP PROCEDURE IF EXISTS 'LlamarEjemplo'$$
CREATE DEFINER='root'@'localhost' PROCEDURE 'LlamarLibroCompras_ListarMesPeriodo'(IN rutempresaC VARCHAR(10),IN periodoC INT, IN mesC INT)
BEGIN
DECLARE c_noint INT(12) ;
DECLARE done TINYINT DEFAULT 0;
DECLARE cursor_ejemplo CURSOR FOR
SELECT noint FROM lcomp WHERE periodo=periodoC AND mes=mesC AND rutempresa=rutempresaC;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cursor_ejemplo;
loop1:LOOP
FETCH cursor_ejemplo INTO c_noint;
IF done THEN
LEAVE loop1;
END IF;
IF done=1 THEN
LEAVE loop1;
ELSE
CALL Ejemplo_parametros(rutempresaC,periodoC, mesC,c_noint);
END IF;
END LOOP loop1;
CLOSE cursor_ejemplo;
END$$
DELIMITER ;
What I want is that as I go through the row of the query declared in the cursor cursor_example, I can send the noint value of the lcomp table. What I'm trying to do, and store it in a cursor variable c_noint, and as you go through the row of the table, you will be sending the result as a parameter to Example_parameters. But it does not work for me, since it sends me only one record of the table.
I would like to know how to make such an objective, sending as a parameter the values that are going through in the record of the table.