A colleague once told me to use a temporary table to insert variable data for viewing, but this method is too troublesome, and Mysql does not have a better tool for debugging stored procedures. I googled today and found that I can use the select + variable name method to debug Specific method: Add the following statement to your stored procedure: Then use the cmd program that comes with mysql to enter mysql>. There is a stored procedure as follows 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 ; 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;ELSE select number INTO @b FROM t_seq WHERE id = @a+1; END IF; SELECT @b INTO o_result; END Calling stored procedures in navicat
When you click Run directly, enter in the pop-up input box: 't_factory', 2, '0', @result Tracing stored procedure execution steps MySQL does not have the plsqldevelper tool like Oracle to debug stored procedures, so there are two simple ways to track the execution process: Use a temporary table to record the debugging process. Add select @xxx directly in the stored procedure and view the results in the console: 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 This is the end of this article about the simplest way to debug stored procedures in MySQL. For more information about debugging stored procedures in MySQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Nginx reverse proxy to go-fastdfs case explanation
>>: Conflict resolution when marquee and flash coexist in a page
Query Cache 1. Query Cache Operation Principle Be...
<textarea></textarea> is used to crea...
Think big and small, then redirect. Sometimes Lin...
This article shares the specific code for impleme...
Table of contents 1. DOM Diff 2. Add key attribut...
Service.xml The Server.xml configuration file is ...
1. Overview In the daily operation and maintenanc...
Anyone who has studied or used HTML should be fam...
Preface Under the influence of some CSS interacti...
In my past work, the development server was gener...
If you open some Microsoft documents with LibreOf...
0. Introduction August 18, 2016 Today, I noticed ...
1. Add users and groups 1. Add mysql user group #...
The following two errors were encountered when co...
What is Redis Cluster Redis cluster is a distribu...