25 lines
774 B
SQL
25 lines
774 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`XDiario_beforeInsert`
|
|
BEFORE INSERT ON `XDiario`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
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;
|
|
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;
|
|
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 ;
|