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

33 lines
738 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`parking_new`(vStart INT, vEnd INT, vSectorFk INT)
BEGIN
DECLARE vRow INT;
DECLARE vColumn INT;
DECLARE vLetters VARCHAR(200);
DECLARE vLettersLength INT;
SET vColumn = vStart;
SET vRow = 1;
SET vLetters = 'ABCDEF';
SET vLettersLength = LENGTH(vLetters);
WHILE vColumn <= vEnd DO
REPLACE vn.parking(`column`, `row`, `code`, sectorFk)
VALUES(vColumn, vRow, CONCAT(vColumn,MID(vLetters,vRow,1)), vSectorFk);
SET vRow = vRow + 1;
IF vRow > vLettersLength THEN
SET vRow = 1;
SET vColumn = vColumn + 1;
END IF;
END WHILE;
END$$
DELIMITER ;