2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2025-01-20 13:43:14 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(
|
|
|
|
vNumberPlate VARCHAR(10),
|
|
|
|
vCountryCodeFk VARCHAR(2)
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
2025-01-20 13:43:14 +00:00
|
|
|
* Comprueba si la matricula pasada tiene el formato
|
|
|
|
* correcto dependiendo del pais del vehiculo.
|
|
|
|
*
|
|
|
|
* @param vNumberPlate Número de matricula
|
|
|
|
* @param vCountryCodeFk Código de pais
|
2024-01-15 11:31:03 +00:00
|
|
|
*/
|
|
|
|
DECLARE vRegex VARCHAR(45);
|
|
|
|
|
2025-01-20 13:43:14 +00:00
|
|
|
IF vCountryCodeFk IS NULL THEN
|
|
|
|
SET vRegex = '^[A-Z0-9 -]{6,12}$';
|
|
|
|
ELSE
|
|
|
|
SELECT regex INTO vRegex
|
|
|
|
FROM vehiclePlateRegex
|
|
|
|
WHERE countryCodeFk = vCountryCodeFk;
|
|
|
|
END IF;
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
2025-01-20 13:43:14 +00:00
|
|
|
CALL util.throw(CONCAT('La matricula ', vNumberPlate,
|
|
|
|
' no es valida', IF(vCountryCodeFk IS NOT NULL,
|
|
|
|
CONCAT(' para ', vCountryCodeFk), '')));
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|