This commit is contained in:
parent
aa62f1d483
commit
477646ba31
|
@ -1,17 +1,30 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2))
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(
|
||||||
|
vNumberPlate VARCHAR(10),
|
||||||
|
vCountryCodeFk VARCHAR(2)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Comprueba si la matricula pasada tiene el formato correcto dependiendo del pais del vehiculo
|
* 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
|
||||||
*/
|
*/
|
||||||
DECLARE vRegex VARCHAR(45);
|
DECLARE vRegex VARCHAR(45);
|
||||||
|
|
||||||
SELECT vp.regex INTO vRegex
|
IF vCountryCodeFk IS NULL THEN
|
||||||
FROM vehiclePlateRegex vp
|
SET vRegex = '^[A-Z0-9 -]{6,12}$';
|
||||||
WHERE vp.countryCodeFk = vCountryCodeFk;
|
ELSE
|
||||||
|
SELECT regex INTO vRegex
|
||||||
|
FROM vehiclePlateRegex
|
||||||
|
WHERE countryCodeFk = vCountryCodeFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
||||||
CALL util.throw(CONCAT('Error: la matricula ', vNumberPlate, ' no es valida para ',vCountryCodeFk));
|
CALL util.throw(CONCAT('La matricula ', vNumberPlate,
|
||||||
|
' no es valida', IF(vCountryCodeFk IS NOT NULL,
|
||||||
|
CONCAT(' para ', vCountryCodeFk), '')));
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert`
|
||||||
BEFORE INSERT ON `roadmap`
|
BEFORE INSERT ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.tractorPlate, NULL);
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.trailerPlate, NULL);
|
||||||
IF NEW.driver1Fk IS NOT NULL THEN
|
IF NEW.driver1Fk IS NOT NULL THEN
|
||||||
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
||||||
ELSE
|
ELSE
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
|
||||||
BEFORE UPDATE ON `roadmap`
|
BEFORE UPDATE ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.tractorPlate, NULL);
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.trailerPlate, NULL);
|
||||||
IF NEW.driver1Fk IS NOT NULL THEN
|
IF NEW.driver1Fk IS NOT NULL THEN
|
||||||
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
||||||
ELSE
|
ELSE
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE vn.roadmap
|
||||||
|
MODIFY COLUMN m3 int(10) unsigned DEFAULT NULL NULL COMMENT 'Capacidad máxima del remolque';
|
||||||
|
ALTER TABLE vn.route
|
||||||
|
ADD roadmapStopFk int(11) NULL,
|
||||||
|
ADD CONSTRAINT route_roadmapStop_FK FOREIGN KEY (roadmapStopFk) REFERENCES vn.roadmapStop(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
Loading…
Reference in New Issue