Debugging of MySql stored procedures

A better tool for writing and debugging stored procedures is dbForge studio for mysql

  Check whether the fields of the temporary table meet the requirements, dynamically add field constraints to the temporary table in the stored process, or write a cursor, iterate the data, and judge one by one. When an error is found while the cursor is iterating, you can manually execute an erroneous statement (such as insert into notExists values(1)) to terminate the stored procedure.

  However, with the above constraints or cursor traversal, when an error occurs, the Java calling end only prompts errors such as xxx not exists or xxx should not be null, and does not provide the specific error reported in the stored procedure.

  When operations are performed on the same table in multiple places in the stored procedure, and it is found that the data in this table is abnormal after execution, it is difficult to find out which operation caused the data abnormality. You can only place constraints on multiple places in turn from top to bottom and execute multiple times. Stored procedure to check.

  The most impressive thing is that a certain field in the table is not written in the stored procedure, and the default value is set on the table structure. After executing the stored procedure, it is always null. Manually inserting a value for this field also It is still null, the problem could not be found out, and only one more line of update can be executed in a compromise to update the null to the default value

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325337623&siteId=291194637