18 lines
573 B
MySQL
18 lines
573 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2))
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Comprueba si la matricula pasada tiene el formato correcto dependiendo del pais del vehiculo
|
||
|
*/
|
||
|
DECLARE vRegex VARCHAR(45);
|
||
|
|
||
|
SELECT vp.regex INTO vRegex
|
||
|
FROM vehiclePlateRegex vp
|
||
|
WHERE vp.countryCodeFk = vCountryCodeFk;
|
||
|
|
||
|
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
||
|
CALL util.throw(CONCAT('Error: la matricula ', vNumberPlate, ' no es valida para ',vCountryCodeFk));
|
||
|
END IF;
|
||
|
END$$
|
||
|
DELIMITER ;
|