Ver Mensaje Individual
  #7 (permalink)  
Antiguo 02/04/2015, 07:48
Avatar de gnzsoloyo
gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: cursor mysql, gran duda

Pruebalo asi:
Código MySQL:
Ver original
  1. DROP PROCEDURE IF EXISTS `prueba2`$$
  2.  
  3. CREATE PROCEDURE `prueba2`()
  4.  
  5.    DECLARE rut VARCHAR(10);
  6.      
  7.    
  8.    DECLARE micursor CURSOR FOR SELECT rut_alum FROM alumno WHERE id_curso=13;
  9.    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=TRUE;
  10.    
  11.      
  12.    OPEN micursor;
  13.  
  14.     REPEAT
  15.        FETCH micursor INTO rut;
  16.     IF NOT done THEN
  17.          INSERT INTO libcomunicacion(id_curso,des_com,fech_com,fecha_dada,tipo_com,rut_alum)
  18.          VALUES(13,'comunicacion desde el procedimiento','2015-06-12',NOW(),'r',rut);                              
  19.     END IF;
  20.     UNTIL done END REPEAT;
  21.    
  22.    CLOSE micursor;
  23.    
  24.  END$$
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)