refs #4951 delete function
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-01-11 09:13:18 +01:00
parent 14ca5cc599
commit a42723210f
1 changed files with 4 additions and 23 deletions

View File

@ -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 ;