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

33 lines
736 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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 ;