您好,欢迎访问一九零五行业门户网

mysql如何调试存储过程

mysql调试存储过程的方法:1、利用“create temporary table”语句创建一张临时表,用于记录调试过程;2、在存储过程中,增加“select @xxx”语句;3、打开控制台,在控制台中查看结果,根据输出结果修改代码即可。
本教程操作环境:windows7系统、mysql8版本、dell g3电脑。
mysql调试存储过程的方法:
在navicat中调用存储过程
1. 写语句调用
call p_next_id('t_factory',2,'0',@result); -- 上面的存储过程含有四个参数,所以这里调用的时候,也需要传递4个参数:输入参数填写值,输出参数用变量表示@resultselect @result; -- 这句话是在控制台显示变量值
2. 窗口点击
直接点击运行时,在弹出输入框输入:
't_factory',2,'0',@result
追踪(调试)存储过程执行步骤
mysql不像oracle有plsqldevelper工具用来调试存储过程,所以有两简单的方式追踪执行过程:
利用“create temporary table”语句创建一张临时表,用于记录调试过程
直接在存储过程中,增加select @xxx
在控制台查看结果,根据输出结果修改代码:
例如我把上面的存储过程中加一些查询语句(注意下面的红色语句)
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
【相关学习推荐:mysql学习】
以上就是mysql如何调试存储过程的详细内容。
其它类似信息

推荐信息