File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ # # This stored procedure updates a field between tables comparing a value from a second
2
+
3
+ CREATE DEFINER= ` root` @` localhost` PROCEDURE ` actualiza_entregas` ()
4
+ BEGIN
5
+ DECLARE nom_entregado varchar (255 );
6
+ DECLARE fin integer default 0 ;
7
+
8
+ # select data for iteration
9
+ DECLARE entregados_cursor CURSOR FOR
10
+ SELECT municipio FROM entregados;
11
+
12
+ # exit condition for entregados_cursor
13
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET fin= 1 ;
14
+
15
+ # open cursor
16
+ OPEN entregados_cursor;
17
+
18
+ # begin loop
19
+ get_entregados: LOOP
20
+ # set the value of entregados_cursor to variable nom_entregado
21
+ FETCH entregados_cursor INTO nom_entregado;
22
+ IF fin = 1 THEN
23
+ # if condition ... exit loop
24
+ LEAVE get_entregados;
25
+ END IF;
26
+
27
+ # update the field when nom_entregado like nom loc in second table
28
+ UPDATE georeferencia set registro = 1 where nom_loc like nom_entregado;
29
+
30
+ # end loop
31
+ END LOOP get_entregados;
32
+
33
+ # close the cursor
34
+ close entregados_cursor;
35
+
36
+ END
You can’t perform that action at this time.
0 commit comments