- Loop循环
Declare p_sum number := 0; p_i number; Begin p_i := 1; Loop p_sum := p_sum + p_i; p_i := p_i + 1; If (p_i > 100) then SYS.Dbms_Output.Put_Line(p_sum); Exit; End if; End loop; End;
- while循环
Declare p_sum number := 0; p_i number; Begin p_i := 1; While p_i <= 100 loop p_sum := p_sum + p_i; p_i := p_i + 1; End loop; Dbms_Output.Put_Line(p_sum); End;
- for循环
Declare p_sum number := 0; p_i number; Begin p_i := 1; For p_i in 1..100 loop p_sum := p_sum + p_i; End loop; Dbms_Output.Put_Line(p_sum); End;