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 ):