What is the declaration order of mysql stored procedures?
This article mainly explains "what is the declaration order of mysql stored procedures". The explanation in this article is simple and clear, and is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the declaration order of mysql stored procedures".
The stored procedure begins with three variables, and the order in which they are declared is very important. First, the variable is declared, then the condition is declared, then the cursor is declared, and then the error handler is declared. If it is not declared in order, the system will prompt an error message. As follows:
BEGIN
Declare time char (8)
Declare cur cursor for select date from CDM.cdm_date
DECLARE done INT DEFAULT 0
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1
TRUNCATE table ADM.adm_gtt_appre_analyse
Open cur
Read_loop:LOOP
.
End loop
Close cur
End
Will report an error ERROR 1337 (42000): Variable or condition declaration after cursor or handler declaration
The reason is that declaration cursors (declare cur cursor for select date from CDM.cdm_date;) precede declaration variables (DECLARE done INT DEFAULT 0;)
Thank you for your reading, the above is the content of "what is the declaration order of mysql stored procedures". After the study of this article, I believe you have a deeper understanding of what the declaration order of mysql stored procedures is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!