salix/db/routines/vn/procedures/vehicle_checkNumberPlate.sql

18 lines
577 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;