I want to create a trigger that will allow insert to execute on work hourse (Mon to Fri from 9 am to 5 pm). I currently have this
CREATE DEFINER=`root`@`localhost` TRIGGER `noWorkHour`
BEFORE INSERT ON `empleado` FOR EACH ROW
BEGIN
IF DAYOFWEEK(NOW()) BETWEEN (2, 6)
AND CURTIME() BETWEEN '09:00:00' AND '17:00:00'
THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Solo se pueden ingresar en horario de trabajo';
END IF;
END
But when I try to insert something, it shows:
/* Error de SQL (1241): Operand should contain 1 column(s) */
/* Affected rows: 0 Filas encontradas: 0 Advertencias: 0 Duración para 0 of 1 query: 0,000 sec. */
I use MariaDB for this.