Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the declaration order of mysql stored procedures?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report