From a42723210f81f14463c78fa552504875460570b7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 11 Jan 2023 09:13:18 +0100 Subject: [PATCH] refs #4951 delete function --- db/changes/230201/00-triggersXDiario.sql | 27 ++++-------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/db/changes/230201/00-triggersXDiario.sql b/db/changes/230201/00-triggersXDiario.sql index b31157a3f..5cf0b6253 100644 --- a/db/changes/230201/00-triggersXDiario.sql +++ b/db/changes/230201/00-triggersXDiario.sql @@ -11,7 +11,7 @@ BEGIN IF NEW.SUBCTA <=> '' THEN SET NEW.SUBCTA = NULL; END IF; - IF NEW.SUBCTA IS NOT NULL AND NOT util.checkStringLength(NEW.SUBCTA, 10) THEN + IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN CALL util.throw('INVALID_STRING_LENGTH'); END IF; END IF; @@ -19,7 +19,7 @@ BEGIN IF NEW.CONTRA <=> '' THEN SET NEW.CONTRA = NULL; END IF; - IF NEW.CONTRA IS NOT NULL AND NOT util.checkStringLength(NEW.CONTRA, 10) THEN + IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN CALL util.throw('INVALID_STRING_LENGTH'); END IF; END IF; @@ -54,13 +54,13 @@ BEGIN IF NEW.SUBCTA <=> '' THEN SET NEW.SUBCTA = NULL; END IF; - IF NEW.SUBCTA IS NOT NULL AND NOT util.checkStringLength(NEW.SUBCTA, 10) THEN + 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 util.checkStringLength(NEW.CONTRA, 10) THEN + 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); @@ -71,22 +71,3 @@ BEGIN END$$ DELIMITER ; - -DROP FUNCTION IF EXISTS `util`.`checkStringLength`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`checkStringLength`(vString VARCHAR(255), vLength INT(3)) RETURNS tinyint(1) - DETERMINISTIC -BEGIN -/** - * Comprueba la longitud de un string - * - * @param vString String a comprobar - * @param vLength Longitud que debe tener - * @return Devuelve TRUE/FALSE en caso de que tenga la longitud correcta o no - */ - RETURN LENGTH(vString) <=> vLength; -END$$ -DELIMITER ; -