我正在尝试通过存储过程获取下一个可用的 id,但到目前为止我无法使其工作。这是我的存储过程
DELIMITER $$
USE `devt`$$
DROP PROCEDURE IF EXISTS `updateid`$$
CREATE DEFINER=`root`@`%` PROCEDURE `updateid`(IN `tran_id` VARCHAR(15), IN `typ` VARCHAR(15), OUT `lid` VARCHAR(15))
BEGIN
DECLARE id VARCHAR(15);
SET id = '';
SELECT TranID FROM journal WHERE TranID = tranid INTO id;
read_loop: LOOP
SELECT TranID FROM journal WHERE TranID = id INTO id;
IF id = tran_id THEN
UPDATE journaltype SET journaltype.NextRefNbr = journaltype.NextRefNbr + 1 WHERE journaltype.JournalType = typ;
SELECT journaltype.NextRefNbr FROM journaltype WHERE journaltype.JournalType = typ INTO id;
ITERATE read_loop;
ELSE
SET lid= id;
LEAVE read_loop;
END IF;
END LOOP;
END$$
DELIMITER ;**strong text**
当我运行查询 CALL updateid('17000001','GJ', @test) 我得到一个错误结果由多于一行组成