Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the declaration order of mysql stored procedures?

Shulou Source: shulou.com Published: 2022-05-31 13:57:48 09月13日 Update

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!

Tags: Order procedure storage variable learning three content cursor error importance information reason processor that is ideas situations articles more conditions life Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux MariaDB macOS Shulou Tech Info