这个MySQL代码有什么问题?

时间:2012-07-03 06:09:36

标签: mysql

DELIMITER |
CREATE EVENT CestaTicket
ON SCHEDULE EVERY 1 SECOND
DO 
BEGIN    
 DECLARE var INT;
 DECLARE contador INT; 
 DECLARE valor FLOAT; 
 SET contador=0;
 SET var=0;
 SET valor=0;
 WHILE (var<(SELECT COUNT(DISTINCT IdEmpleado) FROM asistencia WHERE (Asistio=1 AND (Fecha BETWEEN (Now() AND DATE_SUB(CURDATE(),INTERVAL 30 DAY))))))
   SELECT COUNT(IdEmpleado) INTO contador FROM asistencia 
   WHERE (IdEmpleado=var AND Fecha BETWEEN (Now() AND DATE_SUB(CURDATE(),INTERVAL 30 DAY)));

      IF (contador>0)      
      SET valor = contador*0.95*95;      
      INSERT INTO reporte (Emision,Descripcion,Accion,IdEmpleado) 
      VALUES (Now(),CONCAT('El monto asignado para el empleado es: ',CAST(valor AS VARCHAR(30))),'Monto CestaTicket',var);
  END IF;
      var = var + 1;        
  END WHILE;

END |

DELIMITER ;
`

我想知道是否有人可以通过告诉我代码有什么问题帮助我,我是MySQL新句子的新手,所以请耐心等待我!

1 个答案:

答案 0 :(得分:0)

使用“DELIMITER |;”而不是“DELIMITER |”如果您指的是这个错误“您的SQL语法中有错误;请查看与您的MySQL服务器版本对应的手册,以便在正确的语法附近使用')))SELECT COUNT(IdEmpleado)INTO contador FROM asistencia WHERE( IdEm'在第11行“