0

im getting this error in the next stored procedure the biggest issue is that this run without a problem in another computer but not in mine so it makes it difficult to run test of a program that im using.

The error

Error Code: 1267. Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb3_general_ci,COERCIBLE) for operation 'if'

BEGIN
    DECLARE fecha_mysql datetime;
    DECLARE fecha_turno datetime;
    DECLARE dia_pasado int;

    SET @fecha = CURDATE();
    SET @fecha_hora = NOW();
    SET @fecha = IF(@fecha_hora < ADDDATE(@fecha, INTERVAL 1350 MINUTE),@fecha,ADDDATE(@fecha,INTERVAL 1 DAY));
    SET @year = YEAR(@fecha);
    SET @mes = DATE_FORMAT(@fecha,"%m");
    SET @dia = DATE_FORMAT(@fecha,"%d");
    SET @turno_nuevo = CONVERT(CONCAT(@year,@mes,@dia,"01") USING utf8mb4);

    SET @turno = (
        SELECT idTurno 
        FROM turnos 
        WHERE estatus = 0 
        ORDER BY fechaInicio DESC 
        LIMIT 1
    );

    IF(@turno IS NULL) THEN 
        SET @turno = 0;
    ELSE
        SELECT fechaInicio INTO fecha_turno FROM turnos WHERE idTurno = @turno;
        SELECT DAY(fecha_turno) INTO dia_pasado;

        IF(CAST(@dia AS CHAR CHARACTER SET utf8mb4) = CAST(dia_pasado AS CHAR CHARACTER SET utf8mb4)) THEN
            SET @turno_nuevo = @turno+1;
        ELSE
            IF(DATE_FORMAT(fecha_turno,"%H:%i:%s") >= "22:30:00") THEN 
                SET @turno_nuevo = @turno+1;
            END IF;
        END IF;
    END IF;

    SET fecha_mysql = NOW();
    
    UPDATE turnos SET estatus = 1, fechaFin = fecha_mysql WHERE idTurno = @turno;
    
    INSERT INTO turnos(idTurno, idUsuario, nombreTurno, fechaInicio, fechaFin, fechaContable, estatus, turnoAnterior) 
    VALUES(@turno_nuevo, 0, 'turno', fecha_mysql, '0000-00-00 00:00:00', fecha_mysql, 0, @turno);
    
    SELECT CONCAT(CAST(@turno_nuevo AS CHAR CHARACTER SET utf8mb4)) AS vIdTurnoNuevo, fecha_mysql AS fechaInicio;
END

i tried changing some values to utf8mb4 but i still get that a value is (latin1_swedish_ci,IMPLICIT) but i cant actualy find wich one.

0 Answers0