Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/01/2010, 11:08
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, 5 meses
Puntos: 2658
Respuesta: CURSOR arroja Column ... cannot be null cuando consulta es vacia

Código MySQL:
Ver original
  1.  
  2. DECLARE NROSECCION INTEGER;
  3. DECLARE TPROD FLOAT;
  4.  
  5. DECLARE C1 CURSOR FOR
  6. (
  7.     SELECT a.id_acta,seccion_tarj
  8.     FROM `pro_tarja` p, acta a
  9.     WHERE p.id_acta=a.id_acta AND a.id_empr=IDEMPR
  10. );
  11. DECLARE C2 CURSOR FOR
  12. (
  13.     SELECT
  14.     id_tarj, SUM(totproddia_noti) AS totPROD
  15.     FROM notificacion n,acta a, secuencia s, pro_tarja p
  16.     WHERE
  17.     n.id_acta=a.id_acta AND a.id_acta=s.id_acta AND n.id_secu=s.id_secu AND
  18.     p.id_acta=a.id_acta AND p.seccion_tarj=s.numseccion_secu
  19.     AND n.id_acta          =IDACTA
  20.     AND s.numseccion_secu  =NROSECCION
  21. );
  22. DECLARE CONTINUE HANDLER FOR SQLSTATE '02000'
  23.     SET doneC1 = TRUE;
  24.  
  25. -- abro el cursor 1
  26. OPEN C1;
  27.  
  28.     C1_loop:
  29.      LOOP  
  30.         FETCH C1 INTO IDACTA, NROSECCION;  
  31.          
  32.         IF `doneC1` THEN
  33.             LEAVE C1_loop;
  34.         ELSEIF IDACTA IS NOT NULL;
  35.             OPEN C2;
  36.                 FETCH C2 INTO IDTARJ,TPROD;
  37.             CLOSE C2;
  38.         END IF;      
  39.      END LOOP C1_loop;      
  40.  
  41. CLOSE C1;  
  42.  
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)