39 lines
1.2 KiB
SQL
39 lines
1.2 KiB
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`XDiario_beforeUpdate`
|
|
BEFORE UPDATE ON `XDiario`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
IF NOT NEW.SUBCTA <=> OLD.SUBCTA THEN
|
|
IF NEW.SUBCTA <=> '' THEN
|
|
SET NEW.SUBCTA = NULL;
|
|
END IF;
|
|
IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
|
END IF;
|
|
END IF;
|
|
IF NOT NEW.CONTRA <=> OLD.CONTRA THEN
|
|
IF NEW.CONTRA <=> '' THEN
|
|
SET NEW.CONTRA = NULL;
|
|
END IF;
|
|
IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN
|
|
CALL util.throw('INVALID_STRING_LENGTH');
|
|
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 ;
|