Use navicat to create a MySQL stored procedure _ MySQL

Source: Internet
Author: User
Use navicat to create a MySQL stored procedure Navicat

Procedure for creating a stored procedure using Navicat for MySQL:

1. create a function (select the function tag> Click create function ):

2. number, name, and type of parameters of the input function:

3. write the stored procedure:

The code is as follows:

BEGIN/* define variable */declare tmp0 VARCHAR (1000); declare tmp1 VARCHAR (1000); declare done int default-1; -- used to control whether the loop ends/* declare the cursor */declare myCursor cursor for select cell_0, cell_1 from t_test;/* when the cursor reaches the end, mysql automatically sets done = 1 */declare continue handler for not found set done = 1;/* open cursor */open myCursor;/* start loop */myLoop: LOOP/* Move the cursor and assign a value */fetch myCursor into tmp0, tmp1; -- the cursor reaches the end and exits the LOOP if done = 1 then leave myLoop; end if; /* do something */-- Cyclic output information select tmp0, tmp1; -- you can add insert, update, and other statements/* loop end */end loop myLoop; /* close the cursor */close myCursor; END

4. Save (enter a valid name ):

5. run the stored procedure (output information can be queried in Result 1, 2, 3 ):

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.