------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------
This blog for the first contact with the stored procedures of friends to do a guide, the purpose is to solve the cursor does not go round
Many people find that his cursor, whether it is a nested loop or a single-layer loop, will not go, or only walk once, but from the data it should not go one time, I have to tell you the conclusion
A lot of people have a line in these two lines.
' 02000 ' 1 ; 1;
What is the role of it?
In the following execution, once there is a blank record (that is, there is no result returned), or once there is an exception, it will be set to 1, when you loop, judge the done. So there's going to be a recurring problem.
Solution:
1. Abnormal words need to be discharged by themselves
2. In the case of nested loops, a set done=0 must be added after the inner loop is finished;
3. If you check something in the loop or before the loop, and it does not return the record, it will change done to 1, so if you can't delete that query, you have to set done=0 in the back;
The general meaning is this, can try to!!!!!
Mysql: Stored procedure cursors are not in the loop for a detailed explanation