From: http://blog.chinaunix.net/space.php? Uid = 21144244 & Do = Blog & cuid = 1923636 Http://wwty.iteye.com/blog/698210 Let's first introduce the Oracle control statements.
If ElseElsifWhile For Loop
|
The control statement in MySQL is:
If ElseElseifWhile LoopRepeatLeave Iterate
|
The following is an example:
Delimiter / / Create Procedure pro Begin Declare @ A Int Default 5 ; If @ A > 2 Then Select @ A ; Elseif @ A < 5 Then Select 2 ; End If ; End / /
|
The following is the use of loop.
The use of loop should be combined with leave and iterate
I have probably guessed the name.
Leave means to exit the exit loop, while iterate means to continue iteration.
Delimiter / / Create Procedure pro Begin Declare Int Default 1; Label1: loop If < 6 Then Select A ; Set A = A + 1 ; Iterate label1 ; End If ; Leave label1 ; End Loop label1 ; End / /
|
The following is the repeat pull
Delimiter / / Create Procedure pro Begin Declare Int Default 3 ; Repeat Select A ; Set A = A + 1 ; Untile > 5 End Repeat ; End / /
|
The last one is the while statement.
delimiter / / Create procedure pro begin declare a int default 4 ; while a 10 DO select A ; set A = A + 1 ; end while ; end / / |
From the example above, we can see that there is a big difference between Oracle and Oracle.
The value assignment is declared in the begin block through the set instead of the: = declaration variable through the declare.
Oracle has for statements and most of them are loop statements.
For I in 1 .. 5
Loop
Statement
End loop;
While a> 5
Loop
End loop;
Loop
Exit when ();
End Loop