2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`nextShelvingCodeMake`()
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE newShelving VARCHAR(3);
|
|
|
|
DECLARE vCode VARCHAR(3);
|
|
|
|
|
|
|
|
SELECT MAX(code) INTO vCode
|
|
|
|
FROM vn.shelving
|
|
|
|
WHERE isPrinted = FALSE;
|
|
|
|
|
|
|
|
SET @a1 := ASCII(MID(vCode,1,1));
|
|
|
|
SET @a2 := ASCII(MID(vCode,2,1));
|
|
|
|
SET @a3 := ASCII(MID(vCode,3,1)) + 1;
|
|
|
|
|
|
|
|
IF @a3 > 90 THEN
|
|
|
|
|
|
|
|
SET @a3 = 65;
|
|
|
|
SET @a2 = @a2 + 1;
|
|
|
|
|
|
|
|
IF @a2 > 90 THEN
|
|
|
|
|
|
|
|
SET @a2 = 65;
|
|
|
|
SET @a1 = @a1 + 1;
|
|
|
|
|
|
|
|
IF @a1 > 90 THEN
|
|
|
|
|
|
|
|
SET @a1 = 65;
|
|
|
|
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SET newShelving = CHAR(@a1,@a2,@a3 USING utf8);
|
|
|
|
|
|
|
|
INSERT INTO vn.shelving(code) VALUES(newShelving);
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|