mysql调试存储过程

时间:2022-06-29 00:13:42
mysql调试存储过程
CREATE PROCEDURE `p_next_id`(kind_name VARCHAR(30), i_length int,currentSeqNo VARCHAR(3),OUT o_result INT)
BEGIN
SET @a= NULL;
SET @b= NULL;
SELECT id INTO @a FROM t_seq WHERE number= currentSeqNo and length= i_length ;
   SELECT @a; IF (@a is null ) THEN
select min(id) into @a FROM t_seq where length = i_length;
select number INTO @b FROM t_seq WHERE id = @a;
       select @b; ELSE
select number INTO @b FROM t_seq WHERE id = @a+1;
END IF;
SELECT @b INTO o_result;

END

这里会有一个误区,就是

select @b;
不用加@,只把变量抄下来就行;