Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/12/2013, 03:17
nhygren
 
Fecha de Ingreso: diciembre-2013
Mensajes: 1
Antigüedad: 10 años, 5 meses
Puntos: 0
Problemas con MySQL

Buenos días, estoy haciendo una página web en el hosting gratuito de Hostinger, y hasta ahora todo genial, pero necesito crearme un procedimiento.

El Procedimiento contiene un cursor ya que necesito hacer un Update sobre varias líneas y almacenando una serie de valores en variables...

El procedimiento me lo crea bien, pero cuando hago el call, se me queda CARGANDo, y no me hace nada. os dejo el código a continuación.
Código MySQL:
Ver original
  1. CREATE PROCEDURE getPuntosUsuario5()
  2. DECLARE xvariable1 INT;
  3. DECLARE xPiloto VARCHAR(50);
  4. DECLARE xPiloto1 VARCHAR(50);
  5. DECLARE xPiloto2 VARCHAR(50);
  6. DECLARE xPiloto3 VARCHAR(50);
  7. DECLARE xPiloto4 VARCHAR(50);
  8. DECLARE xPiloto5 VARCHAR(50);
  9. DECLARE xPiloto6 VARCHAR(50);
  10. DECLARE xPiloto7 VARCHAR(50);
  11. DECLARE xPiloto8 VARCHAR(50);
  12. DECLARE xPiloto9 VARCHAR(50);
  13. DECLARE xPiloto10 VARCHAR(50);
  14. DECLARE xPilotoPole1 VARCHAR(50);
  15. DECLARE xPilotopole2 VARCHAR(50);
  16. DECLARE xPilotoPole3 VARCHAR(50);
  17. DECLARE xPilotoUltimo VARCHAR(50);
  18. DECLARE xposicion Int;
  19. DECLARE xpole int;
  20. DECLARE xultimo int;
  21. DECLARE xpuntos int;
  22. DECLARE xpos1 int;
  23. DECLARE xpos2 int;
  24. DECLARE xpos3 int;
  25. DECLARE xpos4 int;
  26. DECLARE xpos5 int;
  27. DECLARE xpos6 int;
  28. DECLARE xpos7 int;
  29. DECLARE xpos8 int;
  30. DECLARE xpos9 int;
  31. DECLARE xpos10 int;
  32. DECLARE xpole1 int;
  33. DECLARE xpole2 int;
  34. DECLARE xpole3 int;
  35. DECLARE xpult int;
  36. DECLARE xusuario VARCHAR(75);
  37. DECLARE xliga VARCHAR(100);
  38. DECLARE xfechamodificacion DATETIME;
  39. DECLARE xaciertos int;
  40.  
  41. DECLARE CursorF1 CURSOR FOR
  42.  
  43. SELECT IdUser,Usuario,Liga,fechamodificacion FROM tbAustralia WHERE Temporada = 2013;
  44.  
  45. DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1;
  46.  
  47. OPEN CursorF1;
  48.  
  49.  
  50.     FETCH CursorF1 INTO xID;
  51.  
  52.         SET xvariable1 = 0;
  53.         SET xaciertos = 0;
  54.  
  55.         Select xpos1 = Primero, xpos2 = Segundo, xpos3 = Tercero, xpos4 = Cuarto, xpos5 = Quinto, xpos6 = Sexto, xpos7 = Septimo, xpos8 = Octavo, xpos9 = Noveno, xpos10 = Decimo, xpole1 = pole1, xpole2 = pole2, xpole3 = pole3, xpult = ultimo FROM tbAustralia
  56.         WHERE IDUser = xID;
  57.        
  58.         Select xPiloto1 = Piloto FROM tbPosiciones WHERE  Australia = 1 and Temporada = 2013;
  59.         Select xPiloto2 = Piloto FROM tbPosiciones WHERE  Australia = 2 and Temporada = 2013;
  60.         Select xPiloto3 = Piloto FROM tbPosiciones WHERE  Australia = 3 and Temporada = 2013;
  61.         Select xPiloto4 = Piloto FROM tbPosiciones WHERE  Australia = 4 and Temporada = 2013;
  62.         Select xPiloto5 = Piloto FROM tbPosiciones WHERE  Australia = 5 and Temporada = 2013;
  63.         Select xPiloto6 = Piloto FROM tbPosiciones WHERE  Australia = 6 and Temporada = 2013;
  64.         Select xPiloto7 = Piloto FROM tbPosiciones WHERE  Australia = 7 and Temporada = 2013;
  65.         Select xPiloto8 = Piloto FROM tbPosiciones WHERE  Australia = 8 and Temporada = 2013;
  66.         Select xPiloto9 = Piloto FROM tbPosiciones WHERE  Australia = 9 and Temporada = 2013;
  67.         Select xPiloto10 = Piloto FROM tbPosiciones WHERE  Australia = 10 and Temporada = 2013;
  68.  
  69.         Select xPilotoPole1 = Piloto FROM tbPoles WHERE  Australia = 1 and Temporada = 2013;
  70.         Select xPilotoPole2 = Piloto FROM tbPoles WHERE  Australia = 2 and Temporada = 2013;
  71.         Select xPilotoPole3 = Piloto FROM tbPoles WHERE  Australia = 3 and Temporada = 2013;
  72.  
  73.         Select xPilotoUltimo = Piloto FROM tbUltimos WHERE  Australia = 1 and Temporada = 2013;
  74.  
  75.         IF xPiloto1 = xPos1 THEN   
  76.             SET xvariable1 = xvariable1 + 25;
  77.             SET xaciertos = xaciertos + 1;
  78.         END IF;
  79.         IF xPiloto2 = xPos2 THEN   
  80.             SET xvariable1 = xvariable1 + 18;
  81.             SET xaciertos = xaciertos + 1;
  82.         END IF;
  83.         IF xPiloto3 = xPos3 THEN   
  84.             SET xvariable1 = xvariable1 + 15;
  85.             SET xaciertos = xaciertos + 1;
  86.         END IF;
  87.         IF xPiloto4 = xPos4 THEN   
  88.             SET xvariable1 = xvariable1 + 12;
  89.             SET xaciertos = xaciertos + 1;
  90.         END IF;
  91.         IF xPiloto5 = xPos5 THEN   
  92.             SET xvariable1 = xvariable1 + 10;
  93.             SET xaciertos = xaciertos + 1;
  94.         END IF;
  95.         IF xPiloto6 = xPos6 THEN   
  96.             SET xvariable1 = xvariable1 + 8;
  97.             SET xaciertos = xaciertos + 1;
  98.         END IF;
  99.         IF xPiloto7 = xPos7 THEN   
  100.             SET xvariable1 = xvariable1 + 6;
  101.             SET xaciertos = xaciertos + 1;
  102.         END IF;
  103.         IF xPiloto8 = xPos8 THEN   
  104.             SET xvariable1 = xvariable1 + 4;
  105.             SET xaciertos = xaciertos + 1;
  106.         END IF;
  107.         IF xPiloto9 = xPos9 THEN   
  108.             SET xvariable1 = xvariable1 + 2;
  109.             SET xaciertos = xaciertos + 1;
  110.         END IF;
  111.         IF xPiloto10 = xPos10 THEN 
  112.             SET xvariable1 = xvariable1 + 1;
  113.             SET xaciertos = xaciertos + 1;
  114.         END IF;
  115.  
  116.         IF xPilotoPole1 = xPole1 THEN  
  117.             SET xvariable1 = xvariable1 + 15;
  118.             SET xaciertos = xaciertos + 1;
  119.         END IF;
  120.         IF xPilotoPole2 = xPole2 THEN  
  121.             SET xvariable1 = xvariable1 + 10;
  122.             SET xaciertos = xaciertos + 1;
  123.         END IF;
  124.         IF xPilotoPole3 = xPole3 THEN  
  125.             SET xvariable1 = xvariable1 + 8;
  126.             SET xaciertos = xaciertos + 1;
  127.         END IF;
  128.  
  129.         IF xPilotoUltimo = xpult THEN  
  130.             SET xvariable1 = xvariable1 + 5;
  131.             SET xaciertos = xaciertos + 1;
  132.         END IF;
  133.  
  134.         IF xaciertos > 2 and xaciertos < 4 THEN
  135.             SET xvariable1 = xvariable1 + 10;
  136.         END IF;
  137.  
  138.  
  139.  
  140.             UPDATE tbAustralia SET Puntos = xvariable1
  141.         WHERE IdUser = xID;
  142.  
  143. UNTIL done END REPEAT;         
  144. CLOSE CursorF1;
  145. END$$

Última edición por gnzsoloyo; 13/12/2013 a las 03:34