2023-01-04 07:36:55 +00:00
|
|
|
DROP TRIGGER IF EXISTS vn.XDiario_beforeUpdate;
|
|
|
|
USE vn;
|
|
|
|
|
|
|
|
DELIMITER $$
|
|
|
|
$$
|
|
|
|
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`XDiario_beforeUpdate`
|
|
|
|
BEFORE UPDATE ON `XDiario`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
IF NOT NEW.SUBCTA <=> OLD.SUBCTA THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
IF NEW.SUBCTA <=> '' THEN
|
|
|
|
SET NEW.SUBCTA = NULL;
|
|
|
|
END IF;
|
2023-01-11 08:13:18 +00:00
|
|
|
IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
2023-01-04 07:36:55 +00:00
|
|
|
END IF;
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.CONTRA <=> OLD.CONTRA THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
IF NEW.CONTRA <=> '' THEN
|
|
|
|
SET NEW.CONTRA = NULL;
|
|
|
|
END IF;
|
2023-01-11 08:13:18 +00:00
|
|
|
IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
2023-01-04 07:36:55 +00:00
|
|
|
END IF;
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.FECHA <=> OLD.FECHA THEN
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA);
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.FECHA_EX <=> OLD.FECHA_EX THEN
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_EX);
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.FECHA_OP <=> OLD.FECHA_OP THEN
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_OP);
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.FECHA_RT <=> OLD.FECHA_RT THEN
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_RT);
|
|
|
|
END IF;
|
|
|
|
IF NOT NEW.FECREGCON <=> OLD.FECREGCON THEN
|
|
|
|
CALL XDiario_checkDate(NEW.FECREGCON);
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|
|
|
|
|
|
|
|
|
|
|
|
DROP TRIGGER IF EXISTS vn.XDiario_beforeInsert;
|
|
|
|
USE vn;
|
|
|
|
|
|
|
|
DELIMITER $$
|
|
|
|
$$
|
|
|
|
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`XDiario_beforeInsert`
|
|
|
|
BEFORE INSERT ON `XDiario`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
2023-01-04 09:37:59 +00:00
|
|
|
IF NEW.SUBCTA <=> '' THEN
|
|
|
|
SET NEW.SUBCTA = NULL;
|
|
|
|
END IF;
|
2023-01-11 08:13:18 +00:00
|
|
|
IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
2023-01-04 07:36:55 +00:00
|
|
|
END IF;
|
2023-01-04 09:37:59 +00:00
|
|
|
IF NEW.CONTRA <=> '' THEN
|
|
|
|
SET NEW.CONTRA = NULL;
|
|
|
|
END IF;
|
2023-01-11 08:13:18 +00:00
|
|
|
IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN
|
2023-01-04 09:37:59 +00:00
|
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
2023-01-04 07:36:55 +00:00
|
|
|
END IF;
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA);
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_EX);
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_OP);
|
|
|
|
CALL XDiario_checkDate(NEW.FECHA_RT);
|
|
|
|
CALL XDiario_checkDate(NEW.FECREGCON);
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|
|
|
|
|